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.


Methods

init

public static init(): void
  • This method is static.

load

Loads the module and initializes the other actions.

public static load(): bool
  • This method is static.

logout

Clear variables and potentially create a flag for the logout of TouchPoint.

public static logout(): void
  • This method is static.

footer

Placeholder for automatic login.

public static footer(): mixed

TODO: this

  • This method is static.

printLoginLink

Renders the link used to log in through TouchPoint.

public static printLoginLink(): void
  • This method is static.

getLoginUrl

Generates the URL used to initiate a sign-in with TouchPoint.

public static getLoginUrl(): string
  • This method is static. Return Value:

The authorization URL used for a TouchPoint login.


redirectLoginFormMaybe

Determines whether to redirect to the TouchPoint login automatically, and does so if appropriate.

public static redirectLoginFormMaybe(): void
  • This method is static.

redirectLoginCompleteMaybe

Determines whether to redirect to allow the user to continue to the destination page after logging in.

public static redirectLoginCompleteMaybe(string $redirect_to, ?string $requested_redirect_to = null, \WP_User|\WP_Error|null $user = null): string
  • This method is static. Parameters:
Parameter Type Description
$redirect_to string
$requested_redirect_to ?string
$user \WP_User|\WP_Error|null

removeAdminBarMaybe

Prevents the admin bar from being displayed for users who can't edit or change anything.

public static removeAdminBarMaybe(): void
  • This method is static.

preventAdminAccessMaybe

Prevents access to the WordPress admin area for users who can't edit or change anything.

public static preventAdminAccessMaybe(): void
  • This method is static.

overwriteProfileUrl

Replace the default WordPress profile link with a link to the user's TouchPoint profile.

public static overwriteProfileUrl(string $url): string
  • This method is static. Parameters:
Parameter Type Description
$url string

getProfileUrl

Assembles the URL to the TouchPoint profile for a given People ID. Assumes current user if no peopleId is given.

public static getProfileUrl(int|null $peopleId = null): string|null
  • This method is static. Parameters:
Parameter Type Description
$peopleId int|null

api

Handle API requests

public static api(array $uri): bool
  • This method is static. Parameters:
Parameter Type Description
$uri array The request URI already parsed by parse_url()

Return Value:

False if endpoint is not found. Should print the result.


authenticate

Authenticates the user with TouchPoint

public static authenticate(\WP_Error|\WP_User|null $user, mixed $username, mixed $password): \WP_Error|\WP_User|null
  • This method is static. Parameters:
Parameter Type Description
$user \WP_Error|\WP_User|null 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.

Return Value:

The authenticated WP_User, or a WP_Error if there were errors. The WP API expects WP_Error