Authenticate_Handler implements Registerable, Standard_Service

Handles authentication for the Document Library Login Form

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Registerable
Standard_Service

Table of Contents

CATEGORY_COOKIE_PREFIX  = 'dlp_category_unlocks_'
DOCUMENT_COOKIE_PREFIX  = 'dlp_document_unlocks_'
GLOBAL_COOKIE_PREFIX  = 'dlp_global_unlocks_'
prevent_caching()  : mixed
Prevent caching on pages with login form
process_password_login()  : mixed
Process the password login form.
process_user_login()  : mixed
Process the user login form.
register()  : mixed
{@inheritdoc}
cleanup_expired_unlocks()  : array<string|int, mixed>
Remove expired entries from unlock array
get_all_password_protected_categories()  : array<string|int, mixed>
Get all protected category IDs
get_all_protected_document_ids()  : array<string|int, mixed>
Get all protected document IDs
get_category_document_ids()  : array<string|int, mixed>
Get document IDs within a specific category
get_cookie_data()  : array<string|int, mixed>|false
Generic cookie reader with JSON parsing
get_cookie_name_for_type()  : string
Get appropriate cookie name for unlock type
handle_login_redirect()  : mixed
Handle login redirect
set_access_session()  : mixed
Set access session via transients
set_cookie_data()  : bool
Generic cookie writer with JSON encoding
set_login_notice()  : mixed
Set login notice via transients
store_category_unlock()  : bool
Store category password unlock
store_document_unlock()  : bool
Store document password unlock
store_global_unlock()  : bool
Store global password unlock
store_password_unlock()  : mixed
Store password unlock information in cookies
validate_and_store_protection_password()  : bool
Validate password for protection info
validate_category_context_password()  : bool
Validate password for category archive context
validate_category_password()  : bool
Validate password against category protection
validate_document_context_password()  : bool
Validate password for document context
validate_document_password()  : bool
Validate password against document protection
validate_global_context_password()  : bool
Validate password for global document library context
validate_global_password()  : bool
Validate password against global settings
validate_password_access()  : bool
Validate password against document/category protection

Constants

public mixed CATEGORY_COOKIE_PREFIX = 'dlp_category_unlocks_'
Tags
public mixed DOCUMENT_COOKIE_PREFIX = 'dlp_document_unlocks_'
Tags

Methods

prevent_caching()

Prevent caching on pages with login form

public prevent_caching() : mixed
Tags
Return values
mixed

process_password_login()

Process the password login form.

public process_password_login() : mixed
Tags
throws
Exception

If the password is invalid.

Return values
mixed

process_user_login()

Process the user login form.

public process_user_login() : mixed
Tags
throws
Exception

If the user login fails.

Return values
mixed

cleanup_expired_unlocks()

Remove expired entries from unlock array

private cleanup_expired_unlocks(array<string|int, mixed> $unlocks) : array<string|int, mixed>
Parameters
$unlocks : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_all_password_protected_categories()

Get all protected category IDs

private get_all_password_protected_categories() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_all_protected_document_ids()

Get all protected document IDs

private get_all_protected_document_ids() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>

get_category_document_ids()

Get document IDs within a specific category

private get_category_document_ids(int $category_id) : array<string|int, mixed>
Parameters
$category_id : int
Tags
Return values
array<string|int, mixed>

Generic cookie reader with JSON parsing

private get_cookie_data(string $cookie_name) : array<string|int, mixed>|false
Parameters
$cookie_name : string
Tags
Return values
array<string|int, mixed>|false

Get appropriate cookie name for unlock type

private get_cookie_name_for_type(string $type) : string
Parameters
$type : string
Tags
Return values
string

handle_login_redirect()

Handle login redirect

private handle_login_redirect(string $redirect_url) : mixed
Parameters
$redirect_url : string

The URL to redirect to.

Tags
Return values
mixed

set_access_session()

Set access session via transients

private set_access_session(string $type, mixed $data) : mixed
Parameters
$type : string

The type of access (e.g. 'password', 'user').

$data : mixed

The data to store in the session.

Tags
Return values
mixed

Generic cookie writer with JSON encoding

private set_cookie_data(string $cookie_name, array<string|int, mixed> $data, int $expires) : bool
Parameters
$cookie_name : string
$data : array<string|int, mixed>
$expires : int
Tags
Return values
bool

set_login_notice()

Set login notice via transients

private set_login_notice(string $message[, string $type = 'error' ]) : mixed
Parameters
$message : string

Login notice message.

$type : string = 'error'

Login notice type (default is 'error').

This method stores a login notice in the WordPress transient storage for a short duration, allowing it to be displayed to the user on the next page load. The notice includes a message and a type, which can be used to style the notice appropriately.

Tags
Return values
mixed

store_category_unlock()

Store category password unlock

private store_category_unlock(int $term_id, string $taxonomy, string $password) : bool
Parameters
$term_id : int
$taxonomy : string
$password : string
Tags
Return values
bool

store_document_unlock()

Store document password unlock

private store_document_unlock(int $document_id, string $password) : bool
Parameters
$document_id : int
$password : string
Tags
Return values
bool

store_global_unlock()

Store global password unlock

private store_global_unlock(string $password) : bool
Parameters
$password : string
Tags
Return values
bool

store_password_unlock()

Store password unlock information in cookies

private store_password_unlock(string $type, int|null $object_id, string $password) : mixed
Parameters
$type : string

'global', 'category', or 'document'

$object_id : int|null
$password : string
Tags
Return values
mixed

validate_and_store_protection_password()

Validate password for protection info

private validate_and_store_protection_password(string $password, array<string|int, mixed> $protection_info) : bool
Parameters
$password : string

Password to validate.

$protection_info : array<string|int, mixed>

The protection info to validate against.

Tags
Return values
bool

Whether the password is valid.

validate_category_context_password()

Validate password for category archive context

private validate_category_context_password(string $password, array<string|int, mixed> $context) : bool
Parameters
$password : string

Password to validate.

$context : array<string|int, mixed>

The context to validate against.

Tags
Return values
bool

Whether the password is valid.

validate_category_password()

Validate password against category protection

private validate_category_password(int $category_id, string $password) : bool
Parameters
$category_id : int
$password : string
Tags
Return values
bool

validate_document_context_password()

Validate password for document context

private validate_document_context_password(string $password, array<string|int, mixed> $context) : bool
Parameters
$password : string

Password to validate.

$context : array<string|int, mixed>

The context to validate against.

Tags
Return values
bool

Whether the password is valid.

validate_document_password()

Validate password against document protection

private validate_document_password(int $document_id, string $password) : bool
Parameters
$document_id : int
$password : string
Tags
Return values
bool

validate_global_context_password()

Validate password for global document library context

private validate_global_context_password(string $password) : bool
Parameters
$password : string

Password to validate.

Tags
Return values
bool

Whether the password is valid.

validate_global_password()

Validate password against global settings

private validate_global_password(string $password) : bool
Parameters
$password : string
Tags
Return values
bool

validate_password_access()

Validate password against document/category protection

private validate_password_access(string $password, array<string|int, mixed> $context) : bool
Parameters
$password : string

Password to validate.

$context : array<string|int, mixed>

The context to validate against.

Tags
Return values
bool

Whether the password is valid.

Search results