function UserAuthentication::authenticateAccount
Same name and namespace in other branches
- 11.x core/modules/user/src/UserAuthentication.php \Drupal\user\UserAuthentication::authenticateAccount()
Validates user authentication credentials for an account.
This can be used where the account has already been located using the login credentials.
Parameters
\Drupal\Core\Session\AccountInterface $account: The account to authenticate.
string $password: A plain-text password, such as trimmed text from form values.
Return value
bool TRUE on success, FALSE on failure.
Overrides UserAuthenticationInterface::authenticateAccount
1 call to UserAuthentication::authenticateAccount()
- UserAuthentication::authenticate in core/
modules/ user/ src/ UserAuthentication.php
File
-
core/
modules/ user/ src/ UserAuthentication.php, line 76
Class
- UserAuthentication
- Validates user authentication credentials.
Namespace
Drupal\userCode
public function authenticateAccount(UserInterface $account, string $password) : bool {
if ($this->passwordChecker
->check($password, $account->getPassword())) {
// Update user to new password scheme if needed.
if ($this->passwordChecker
->needsRehash($account->getPassword())) {
$account->setPassword($password);
$account->save();
}
return TRUE;
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.