Elgg  Version 5.1
Public Member Functions | Protected Attributes | List of all members
Elgg\Users\Accounts Class Reference

User accounts service. More...

Public Member Functions

 __construct (Config $config, Translator $translator, PasswordService $passwords, EventsService $events, EmailService $email, PasswordGeneratorService $password_generator)
 Constructor. More...
 
 validateAccountData (string $username, string|array $password, string $name, string $email, bool $allow_multiple_emails=false)
 Validate registration details to ensure they can be used to register a new user account. More...
 
 assertValidAccountData (string $username, string|array $password, string $name, string $email, bool $allow_multiple_emails=false)
 Assert that given registration details are valid and can be used to register the user. More...
 
 register (array $params=[])
 Registers a user. More...
 
 assertValidUsername (string $username, bool $assert_unregistered=false)
 Simple function which ensures that a username contains only valid characters. More...
 
 assertValidPassword (string|array $password)
 Simple validation of a password. More...
 
 assertCurrentPassword (\ElggUser $user, string $password)
 Assert that user can authenticate with the given password. More...
 
 assertValidEmail (string $address, bool $assert_unregistered=false)
 Simple validation of a email. More...
 
 isValidEmail (string $address)
 Validates an email address. More...
 
 requestNewEmailValidation (\ElggUser $user, string $email)
 Send out an e-mail to the new email address the user wanted. More...
 
 registerAuthenticationFailure (\ElggUser $user)
 Registers an authentication failure for a user. More...
 
 resetAuthenticationFailures (\ElggUser $user)
 Resets all authentication failures for a given user. More...
 
 isAuthenticationFailureLimitReached (\ElggUser $user, int $limit=null, int $lifetime=null)
 Checks if the authentication failure limit has been reached. More...
 

Protected Attributes

 $config
 
 $translator
 
 $passwords
 
 $events
 
 $email
 
 $password_generator
 

Detailed Description

User accounts service.

Definition at line 20 of file Accounts.php.

Constructor & Destructor Documentation

Elgg\Users\Accounts::__construct ( Config  $config,
Translator  $translator,
PasswordService  $passwords,
EventsService  $events,
EmailService  $email,
PasswordGeneratorService  $password_generator 
)

Constructor.

Parameters
Config$configConfig
Translator$translatorTranslator
PasswordService$passwordsPasswords
EventsService$eventsEvents service
EmailService$emailEmail service
PasswordGeneratorService$password_generatorPassword generator service

Definition at line 62 of file Accounts.php.

Member Function Documentation

Elgg\Users\Accounts::assertCurrentPassword ( \ElggUser  $user,
string  $password 
)

Assert that user can authenticate with the given password.

Parameters
\ElggUser$userUser entity
string$passwordPassword
Returns
void
Exceptions
RegistrationException

Definition at line 338 of file Accounts.php.

Elgg\Users\Accounts::assertValidAccountData ( string  $username,
string|array  $password,
string  $name,
string  $email,
bool  $allow_multiple_emails = false 
)

Assert that given registration details are valid and can be used to register the user.

Parameters
string$usernameThe username of the new user
string | array$passwordThe password
string$nameThe user's display name
string$emailThe user's email address
bool$allow_multiple_emailsAllow the same email address to be registered multiple times?
Returns
void
Exceptions
RegistrationException

Definition at line 143 of file Accounts.php.

Elgg\Users\Accounts::assertValidEmail ( string  $address,
bool  $assert_unregistered = false 
)

Simple validation of a email.

Parameters
string$addressEmail address
bool$assert_unregisteredAlso assert that the email address has not yet been used for a user account
Returns
void
Exceptions
RegistrationException

Definition at line 353 of file Accounts.php.

Elgg\Users\Accounts::assertValidPassword ( string|array  $password)

Simple validation of a password.

Parameters
string | array$passwordClear text password Can be an array [$password, $confirm_password]
Returns
void
Exceptions
RegistrationException

Definition at line 303 of file Accounts.php.

Elgg\Users\Accounts::assertValidUsername ( string  $username,
bool  $assert_unregistered = false 
)

Simple function which ensures that a username contains only valid characters.

This should only permit chars that are valid on the file system as well.

Parameters
string$usernameUsername
bool$assert_unregisteredAlso assert that the username has not yet been registered
Returns
void
Exceptions
RegistrationException

Definition at line 231 of file Accounts.php.

Elgg\Users\Accounts::isAuthenticationFailureLimitReached ( \ElggUser  $user,
int  $limit = null,
int  $lifetime = null 
)

Checks if the authentication failure limit has been reached.

Parameters
\ElggUser$userUser to check the limit for
int$limit(optional) number of allowed failures
int$lifetime(optional) number of seconds before a failure is considered expired
Returns
bool
Since
4.3

Definition at line 474 of file Accounts.php.

Elgg\Users\Accounts::isValidEmail ( string  $address)

Validates an email address.

Parameters
string$addressEmail address
Returns
bool

Definition at line 387 of file Accounts.php.

Elgg\Users\Accounts::register ( array  $params = [])

Registers a user.

Parameters
array$paramsArray of options with keys: (string) username => The username of the new user (string) password => The password (string) name => The user's display name (string) email => The user's email address (string) subtype => (optional) Subtype of the user entity (string) language => (optional) user language (defaults to current language) (bool) allow_multiple_emails => (optional) Allow the same email address to be registered multiple times (default false) (bool) validated => (optional) Is the user validated (default true)
Returns
Exceptions
RegistrationException

Definition at line 170 of file Accounts.php.

Elgg\Users\Accounts::registerAuthenticationFailure ( \ElggUser  $user)

Registers an authentication failure for a user.

Parameters
\ElggUser$useruser to log the failure for
Returns
void
Since
4.3

Definition at line 435 of file Accounts.php.

Elgg\Users\Accounts::requestNewEmailValidation ( \ElggUser  $user,
string  $email 
)

Send out an e-mail to the new email address the user wanted.

Parameters
\ElggUser$useruser with new e-mail address
string$emailE-mail address
Returns
bool
Exceptions
InvalidArgumentException

Definition at line 400 of file Accounts.php.

Elgg\Users\Accounts::resetAuthenticationFailures ( \ElggUser  $user)

Resets all authentication failures for a given user.

Parameters
\ElggUser$useruser to clear the failures for
Returns
void
Since
4.3

Definition at line 451 of file Accounts.php.

Elgg\Users\Accounts::validateAccountData ( string  $username,
string|array  $password,
string  $name,
string  $email,
bool  $allow_multiple_emails = false 
)

Validate registration details to ensure they can be used to register a new user account.

Parameters
string$usernameThe username of the new user
string | array$passwordThe password Can be an array [$password, $oonfirm_password]
string$nameThe user's display name
string$emailThe user's email address
bool$allow_multiple_emailsAllow the same email address to be registered multiple times?
Returns
ValidationResults

Definition at line 91 of file Accounts.php.

Member Data Documentation

Elgg\Users\Accounts::$config
protected

Definition at line 25 of file Accounts.php.

Elgg\Users\Accounts::$email
protected

Definition at line 45 of file Accounts.php.

Elgg\Users\Accounts::$events
protected

Definition at line 40 of file Accounts.php.

Elgg\Users\Accounts::$password_generator
protected

Definition at line 50 of file Accounts.php.

Elgg\Users\Accounts::$passwords
protected

Definition at line 35 of file Accounts.php.

Elgg\Users\Accounts::$translator
protected

Definition at line 30 of file Accounts.php.


The documentation for this class was generated from the following file: