RdbAdmin Module

ForgotLoginPassController extends BaseController
in package
uses UsersTrait

Forgot login, password controller.

Tags
since
0.1

Table of Contents

Properties

$Input  : Input
$Languages  : Languages
$runnedCronResult  : array<string|int, mixed>
$userRow  : object|null

Methods

__construct()  : mixed
{@inheritDoc}
indexAction()  : string
Display forgot login & password page.
resetAction()  : string
Display new password form fields page.
submitRequestAction()  : string
Submit reset password request.
submitResetAction()  : string
Submit new password.
addUpdateUserFormValidation()  : array<string|int, mixed>
Form validation for add and update user.
decryptUserFieldsKey()  : string
Decrypt user fields key.
generateUserFieldsKey()  : array<string|int, mixed>
Generate user fields key.
getConfig()  : array<string|int, mixed>
Get common use configuration between methods.
getPageHtmlClasses()  : string
Get page HTML classes.
getPageHtmlTitle()  : string
Get page HTML title including site name if it was set.
getUserUrlsMethods()  : array<string|int, mixed>
Get URLs and methods about user pages.
isUserProxy()  : bool
Check if user is using proxy.
logoutUser()  : mixed
Logout target user.
maybeRunCron()  : mixed
Maybe run cron job if config is set to not use server cron.
responseJson()  : string
{@inheritDoc}
responseXml()  : string
{@inheritDoc}
setBasicConfig()  : mixed
Setup basic PHP configurations such as default timezone.
setHeaderAllowOrigin()  : mixed
Set header allow origin for CORS.
generateResetPasswordKey()  : array<string|int, mixed>
Generate reset password key if not exists or expired.
isModuleExcute()  : bool
Check if current call is `Modules->execute()`
removeSensitiveCfgInfo()  : array<string|int, mixed>
Remove sensitive config info that contains non-site configuration.
validateResetPasswordKey()  : bool
Validate reset password key. Also validate that user is really exists in DB.

Properties

$runnedCronResult

protected array<string|int, mixed> $runnedCronResult = []

Runned cron jobs result. This is for use in case that set cron job, cron tab to run by URL. The CronController will be call to this BaseController. So, it is no need to using Libraries\Cron class to run jobs again. Just get the run result from this property. This property will be set by maybeRunCron() method.

$userRow

protected object|null $userRow

The user row that get from users table. This property is for get and access across methods without get it again and again.

Methods

__construct()

{@inheritDoc}

public __construct(Container $Container) : mixed
Parameters
$Container : Container

submitRequestAction()

Submit reset password request.

public submitRequestAction() : string

Verify email and then generate secret key and its expire send to email.
User have to enter the link in that email to proceed reset password in next step.

Return values
string

addUpdateUserFormValidation()

Form validation for add and update user.

protected addUpdateUserFormValidation(array<string|int, mixed> $data[, array<string|int, mixed> $dataField = [] ][, array<string|int, mixed> $dataUsersRoles = [] ][, string $saveType = 'insert' ][, string|int $user_id = '' ]) : array<string|int, mixed>

Validate required and valid form fields.
Validate that selected roles did not have higher priority that the user who add or update them.
Validate username and email must not exists.
This method was called from doAddAction() method.

Parameters
$data : array<string|int, mixed>

The associative array form data.

$dataField : array<string|int, mixed> = []

Associative array for user_fields table.

$dataUsersRoles : array<string|int, mixed> = []

Associative array for users_roles table.

$saveType : string = 'insert'

Type of saving data. It can be 'insert' or 'update'. Default is 'insert'.

$user_id : string|int = ''

The user_id to check where $saveType is 'update' that any user else data must be unique.

Return values
array<string|int, mixed>

Return associative array with keys if contain at least one error:
formResultStatus (if error),
formResultMessage (if error) The result message,
formFieldsValidation (optional) Fields that contain errors,
responseStatus (optional) For HTTP response status,

decryptUserFieldsKey()

Decrypt user fields key.

protected decryptUserFieldsKey(string|object $encryptedKey) : string
Parameters
$encryptedKey : string|object

The encrypted key string. Or you may set user_fields object from PDO query instead.

Return values
string

Return decrypted key string or return empty string if failed to decrypted.

generateUserFieldsKey()

Generate user fields key.

protected generateUserFieldsKey([int $length = 8 ]) : array<string|int, mixed>

Generate keys that can be use in change email confirmation, register confirmation, etc.

Parameters
$length : int = 8

The length of key.

Return values
array<string|int, mixed>

Return associative array with 'readableKey', 'encryptedKey' keys.

getConfig()

Get common use configuration between methods.

protected getConfig() : array<string|int, mixed>
Tags
since
1.2.5
Return values
array<string|int, mixed>

getPageHtmlClasses()

Get page HTML classes.

protected getPageHtmlClasses([array<string|int, mixed> $classes = [] ]) : string
Parameters
$classes : array<string|int, mixed> = []

The classes to set for this html page.

Tags
todo

[rdb] Remove auto generate class name rdba-page-, use new one rdba-pagehtml- to prevent duplicate use in many cases. Remove this in v2.0

todo

[rdb] Remove auto generate class name rdba-class-, use new one rdba-calledclass- to prevent duplicate use in many cases. Remove this in v2.0

Return values
string

Return generated html classes names.

getPageHtmlTitle()

Get page HTML title including site name if it was set.

protected getPageHtmlTitle(string $title[, string|null|false $siteName = false ]) : string
Parameters
$title : string

The site title.

$siteName : string|null|false = false

Site name should be string.
Set to empty string or null will not include the site name.
Set to false to automatic get the site name from config DB.

Tags
throws
InvalidArgumentException
Return values
string

getUserUrlsMethods()

Get URLs and methods about user pages.

protected getUserUrlsMethods([string $user_id = '' ]) : array<string|int, mixed>
Parameters
$user_id : string = ''

The user ID.

Return values
array<string|int, mixed>

Return associative array.

logoutUser()

Logout target user.

protected logoutUser([array<string|int, mixed> $cookieData = [] ][, bool $logoutAllDevice = false ]) : mixed
Parameters
$cookieData : array<string|int, mixed> = []

The associative array of cookie data. This value can get from Cookie class. The array keys are:
user_id (required).
sessionKey (optional) For delete specific session key from user_logins table.

$logoutAllDevice : bool = false

Set to true to logout all device, false for specific session key.

maybeRunCron()

Maybe run cron job if config is set to not use server cron.

protected maybeRunCron() : mixed

responseJson()

{@inheritDoc}

protected responseJson(mixed $output) : string
Parameters
$output : mixed
Return values
string

responseXml()

{@inheritDoc}

protected responseXml(mixed $output) : string
Parameters
$output : mixed
Return values
string

setBasicConfig()

Setup basic PHP configurations such as default timezone.

protected setBasicConfig() : mixed

setHeaderAllowOrigin()

Set header allow origin for CORS.

protected setHeaderAllowOrigin() : mixed

generateResetPasswordKey()

Generate reset password key if not exists or expired.

private generateResetPasswordKey(int $user_id) : array<string|int, mixed>
Parameters
$user_id : int

The user ID.

Return values
array<string|int, mixed>

Return associative array with key and time in keys. The time key is date/time value that this key will be expired.

isModuleExcute()

Check if current call is `Modules->execute()`

private isModuleExcute() : bool

This method was called from maybeRunCron(), __construct().

Tags
since
1.2.9
Return values
bool

Return true if it is, false if it is not.

removeSensitiveCfgInfo()

Remove sensitive config info that contains non-site configuration.

private removeSensitiveCfgInfo(array<string|int, mixed> $output) : array<string|int, mixed>
Parameters
$output : array<string|int, mixed>

The output array that contain configDb array key.

Tags
since
1.2.5
Return values
array<string|int, mixed>

Return removed sensitive info.

validateResetPasswordKey()

Validate reset password key. Also validate that user is really exists in DB.

private validateResetPasswordKey(int $user_id, string $userEnteredResetPasswordKey) : bool
Parameters
$user_id : int

The user ID.

$userEnteredResetPasswordKey : string

Original or readable reset password key.

Return values
bool

Return true if success, false for otherwise.


        
On this page

Search results