tp TouchPointWP Auth - TenthPres/TouchPoint-WP GitHub Wiki
tp\TouchPointWP\Auth
Allows users to log in to WordPress with their TouchPoint credentials, and provides other user management functionality.
- Class name: Auth
- Namespace: \tp\TouchPointWP
- This is an abstract class
- This class implements: tp\TouchPointWP\api, tp\TouchPointWP\module
Methods
init
mixed tp\TouchPointWP\Auth::init()
- Visibility: public
- This method is static.
Returns
- mixed
load
bool tp\TouchPointWP\module::load()
Loads the module and initializes the other actions.
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\module
Returns
- bool -
startSession
mixed tp\TouchPointWP\Auth::startSession()
Starts a new session.
- Visibility: public
- This method is static.
Returns
- mixed
logout
mixed tp\TouchPointWP\Auth::logout()
Clear variables and potentially create a flag for the logout of TouchPoint.
Does NOT actually log out of WordPress as this should be called by wp_logout, which accomplishes that.
- Visibility: public
- This method is static.
Returns
- mixed
footer
mixed tp\TouchPointWP\Auth::footer()
Placeholder for automatic login.
- Visibility: public
- This method is static.
Returns
- mixed
printLoginLink
mixed tp\TouchPointWP\Auth::printLoginLink()
Renders the link used to log in through TouchPoint.
- Visibility: public
- This method is static.
Returns
- mixed
getLoginUrl
string tp\TouchPointWP\Auth::getLoginUrl()
Generates the URL used to initiate a sign-in with TouchPoint.
- Visibility: public
- This method is static.
Returns
- string - The authorization URL used for a TouchPoint login.
generateAntiForgeryId
string tp\TouchPointWP\Auth::generateAntiForgeryId()
Get a random string with a timestamp on the end.
- Visibility: public
- This method is static.
Returns
- string -
validateApiKey
string|bool tp\TouchPointWP\Auth::validateApiKey(?string key, ?string host)
- Visibility: public
- This method is static.
Arguments
- key ?string - The api key to test against. If no key is provided, validates the saved key.
- host ?string - The http hostname to use for this key. Will use $_SERVER['HTTP_HOST'] if no value is provided.
Returns
- 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.)
replaceApiKey
string tp\TouchPointWP\Auth::replaceApiKey(mixed host)
Generates a key and saves it.
- Visibility: public
- This method is static.
Arguments
- host mixed
Returns
- string -
redirectLoginFormMaybe
mixed tp\TouchPointWP\Auth::redirectLoginFormMaybe()
Determines whether to redirect to the TouchPoint login automatically, and does so if appropriate.
- Visibility: public
- This method is static.
Returns
- mixed
removeAdminBarMaybe
mixed tp\TouchPointWP\Auth::removeAdminBarMaybe()
Prevents the admin bar from being displayed for users who can't edit or change anything.
- Visibility: public
- This method is static.
Returns
- mixed
overwriteProfileUrl
string tp\TouchPointWP\Auth::overwriteProfileUrl(string url)
Replace the default WordPress profile link with a link to the user's TouchPoint profile.
- Visibility: public
- This method is static.
Arguments
- url string
Returns
- string -
api
bool tp\TouchPointWP\api::api(array uri)
Handle API requests
- Visibility: public
- This method is static.
- This method is defined by tp\TouchPointWP\api
Arguments
- uri array - The request URI already parsed by parse_url()
Returns
- bool - False if endpoint is not found. Should print the result.
authenticate
\WP_User|\WP_Error tp\TouchPointWP\Auth::authenticate(\WP_User|\WP_Error user, mixed username, mixed password)
Authenticates the user with TouchPoint
- Visibility: public
- This method is static.
Arguments
- 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.
Returns
- \WP_User|\WP_Error - The authenticated WP_User, or a WP_Error if there were errors. The WP API expects WP_Error