function UserAuthentication::authenticateAccount

Same name in other branches
  1. 11.x core/modules/user/src/UserAuthentication.php \Drupal\user\UserAuthentication::authenticateAccount()

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\user

Code

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.