Auth
in package
implements
api, module
Allows users to login to WordPress with their TouchPoint credentials, and provides other user management functionality.
Table of Contents
Interfaces
Methods
- api() : bool
- Handle API requests
- authenticate() : WP_User|WP_Error
- Authenticates the user with TouchPoint
- footer() : mixed
- Placeholder for automatic login.
- generateAntiForgeryId() : string
- Get a random string with a timestamp on the end.
- getLoginUrl() : string
- Generates the URL used to initiate a sign-in with TouchPoint.
- init() : void
- load() : bool
- Loads the module and initializes the other actions.
- logout() : mixed
- Clear variables and potentially create a flag for the logout of TouchPoint.
- overwriteProfileUrl() : string
- Replace the default WordPress profile link with a link to the user's TouchPoint profile.
- printLoginLink() : mixed
- Renders the link used to log in through TouchPoint.
- redirectLoginFormMaybe() : mixed
- Determines whether to redirect to the TouchPoint login automatically, and does so if appropriate.
- removeAdminBarMaybe() : mixed
- Prevents the admin bar from being displayed for users who can't edit or change anything.
- replaceApiKey() : string
- Generates a key and saves it.
- startSession() : mixed
- Starts a new session.
- validateApiKey() : string|bool
Methods
api()
Handle API requests
public
static api(array<string|int, mixed> $uri) : bool
Parameters
- $uri : array<string|int, mixed>
-
The request URI already parsed by parse_url()
Return values
bool —False if endpoint is not found. Should print the result.
authenticate()
Authenticates the user with TouchPoint
public
static authenticate(WP_User|WP_Error $user, mixed $username, mixed $password) : WP_User|WP_Error
Parameters
- $user : WP_User|WP_Error
-
A WP_User, if the user has already authenticated.
- $username : mixed
-
The username provided during form-based sign in. Not used.
- $password : mixed
-
The password provided during form-based sign in. Not used.
Tags
Return values
WP_User|WP_Error —The authenticated WP_User, or a WP_Error if there were errors. The WP API expects WP_Error
footer()
Placeholder for automatic login.
public
static footer() : mixed
generateAntiForgeryId()
Get a random string with a timestamp on the end.
public
static generateAntiForgeryId() : string
Return values
stringgetLoginUrl()
Generates the URL used to initiate a sign-in with TouchPoint.
public
static getLoginUrl() : string
Tags
Return values
string —The authorization URL used for a TouchPoint login.
init()
public
static init() : void
load()
Loads the module and initializes the other actions.
public
static load() : bool
Return values
boollogout()
Clear variables and potentially create a flag for the logout of TouchPoint.
public
static logout() : mixed
Does NOT actually log out of WordPress as this should be called by wp_logout, which accomplishes that.
overwriteProfileUrl()
Replace the default WordPress profile link with a link to the user's TouchPoint profile.
public
static overwriteProfileUrl(string $url) : string
Parameters
- $url : string
Return values
stringprintLoginLink()
Renders the link used to log in through TouchPoint.
public
static printLoginLink() : mixed
redirectLoginFormMaybe()
Determines whether to redirect to the TouchPoint login automatically, and does so if appropriate.
public
static redirectLoginFormMaybe() : mixed
removeAdminBarMaybe()
Prevents the admin bar from being displayed for users who can't edit or change anything.
public
static removeAdminBarMaybe() : mixed
replaceApiKey()
Generates a key and saves it.
public
static replaceApiKey( $host) : string
Parameters
Return values
stringstartSession()
Starts a new session.
public
static startSession() : mixed
validateApiKey()
public
static validateApiKey([string|null $key = null ][, string|null $host = null ]) : string|bool
Parameters
- $key : string|null = null
-
The api key to test against. If no key is provided, validates the saved key.
- $host : string|null = null
-
The http hostname to use for this key. Will use $_SERVER['HTTP_HOST'] if no value is provided.
Return values
string|bool —Returns true if the key is valid. Returns false is the key is invalid. Returns a new key if the provided key is valid, but expired. (Does not send it to the server -- that needs to be handled separately.)