UserAuth.php in farmOS 2.x
File
modules/core/login/src/UserAuth.php
View source
<?php
namespace Drupal\farm_login;
use Drupal\user\UserAuth as CoreUserAuth;
class UserAuth extends CoreUserAuth {
public function authenticate($username, $password) {
$uid = parent::authenticate($username, $password);
if (empty($uid) && !empty($username) && strlen($password) > 0) {
$account_search = $this->entityTypeManager
->getStorage('user')
->loadByProperties([
'mail' => $username,
]);
if ($account = reset($account_search)) {
if ($this->passwordChecker
->check($password, $account
->getPassword())) {
$uid = $account
->id();
if ($this->passwordChecker
->needsRehash($account
->getPassword())) {
$account
->setPassword($password);
$account
->save();
}
}
}
}
return $uid;
}
}
Classes
Name |
Description |
UserAuth |
Extends the core user.auth service to load users by their email. |