LimeSurvey API - Master branch

PasswordManagement
in package

This class contains all functions for the process of password reset and creating new administration users and sending email to those with a link to set the password.

All this functions were implemented in UserManagementController before.

Table of Contents

Constants

EMAIL_TYPE_REGISTRATION  = 'registration'
EMAIL_TYPE_RESET_PW  = 'resetPassword'
MIN_PASSWORD_LENGTH  = 8
MIN_TIME_NEXT_FORGOT_PW_EMAIL  = 5

Properties

$user  : User

Methods

__construct()  : mixed
PasswordManagement constructor.
generateAdminCreationEmail()  : mixed
This function prepare the email template to send to the new created user
getRandomPassword()  : string|null
Creates a random password through the core plugin
getRenderArray()  : array<string|int, mixed>
isAllowedToSendForgotPwEmail()  : bool
Checks if user is allowed to do the next sending of email for forgotten password.
sendForgotPasswordEmailLink()  : string
Send a link to email of the user to set a new password (forgot password functionality)
sendPasswordLinkViaEmail()  : array<string|int, mixed>
Sets the validationKey and the validationKey expiration and sends email to the user, containing the link to set/reset password.
sendAdminMail()  : LimeMailer
Send the registration email to a new survey administrator

Constants

Properties

Methods

__construct()

PasswordManagement constructor.

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

\User

generateAdminCreationEmail()

This function prepare the email template to send to the new created user

public generateAdminCreationEmail() : mixed
Return values
mixed

$aAdminEmail array with subject and email body

getRandomPassword()

Creates a random password through the core plugin

public static getRandomPassword([int $length = self::MIN_PASSWORD_LENGTH ]) : string|null
Parameters
$length : int = self::MIN_PASSWORD_LENGTH

Length of the password

Tags
todo

it's fine to use static functions, until it is used only in controllers ...

Return values
string|null

getRenderArray()

public getRenderArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

isAllowedToSendForgotPwEmail()

Checks if user is allowed to do the next sending of email for forgotten password.

public isAllowedToSendForgotPwEmail(User $user) : bool

This should only be the case all 5min (see self::MIN_TIME_NEXT_FORGOT_PW_EMAIL)

Parameters
$user : User
Tags
throws
Exception
Return values
bool

true if user can send another email for forgotten pw, false otherwise

Send a link to email of the user to set a new password (forgot password functionality)

public sendForgotPasswordEmailLink() : string
Return values
string

message for user

sendPasswordLinkViaEmail()

Sets the validationKey and the validationKey expiration and sends email to the user, containing the link to set/reset password.

public sendPasswordLinkViaEmail(string $emailType) : array<string|int, mixed>
Parameters
$emailType : string

this could be 'registration' or 'resetPassword' (see const in this class)

Tags
throws
Exception
Return values
array<string|int, mixed>

message if sending email to user was successful

sendAdminMail()

Send the registration email to a new survey administrator

private sendAdminMail([string $type = self::EMAIL_TYPE_REGISTRATION ]) : LimeMailer
Parameters
$type : string = self::EMAIL_TYPE_REGISTRATION

two types are available 'resetPassword' or 'registration', default is 'registration'

Tags
throws
Exception
Return values
LimeMailer

if send is successful


        
On this page

Search results