Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/UserAuth.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
17:129ea1e6d783 | 18:af1871eacc83 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\user; | 3 namespace Drupal\user; |
4 | 4 |
5 use Drupal\Core\Entity\EntityManagerInterface; | 5 use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; |
6 use Drupal\Core\Entity\EntityTypeManagerInterface; | |
6 use Drupal\Core\Password\PasswordInterface; | 7 use Drupal\Core\Password\PasswordInterface; |
7 | 8 |
8 /** | 9 /** |
9 * Validates user authentication credentials. | 10 * Validates user authentication credentials. |
10 */ | 11 */ |
11 class UserAuth implements UserAuthInterface { | 12 class UserAuth implements UserAuthInterface { |
13 use DeprecatedServicePropertyTrait; | |
12 | 14 |
13 /** | 15 /** |
14 * The entity manager. | 16 * {@inheritdoc} |
17 */ | |
18 protected $deprecatedProperties = ['entityManager' => 'entity.manager']; | |
19 | |
20 /** | |
21 * The entity type manager. | |
15 * | 22 * |
16 * @var \Drupal\Core\Entity\EntityManagerInterface | 23 * @var \Drupal\Core\Entity\EntityTypeManagerInterface |
17 */ | 24 */ |
18 protected $entityManager; | 25 protected $entityTypeManager; |
19 | 26 |
20 /** | 27 /** |
21 * The password hashing service. | 28 * The password hashing service. |
22 * | 29 * |
23 * @var \Drupal\Core\Password\PasswordInterface | 30 * @var \Drupal\Core\Password\PasswordInterface |
25 protected $passwordChecker; | 32 protected $passwordChecker; |
26 | 33 |
27 /** | 34 /** |
28 * Constructs a UserAuth object. | 35 * Constructs a UserAuth object. |
29 * | 36 * |
30 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager | 37 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager |
31 * The entity manager. | 38 * The entity type manager. |
32 * @param \Drupal\Core\Password\PasswordInterface $password_checker | 39 * @param \Drupal\Core\Password\PasswordInterface $password_checker |
33 * The password service. | 40 * The password service. |
34 */ | 41 */ |
35 public function __construct(EntityManagerInterface $entity_manager, PasswordInterface $password_checker) { | 42 public function __construct(EntityTypeManagerInterface $entity_type_manager, PasswordInterface $password_checker) { |
36 $this->entityManager = $entity_manager; | 43 $this->entityTypeManager = $entity_type_manager; |
37 $this->passwordChecker = $password_checker; | 44 $this->passwordChecker = $password_checker; |
38 } | 45 } |
39 | 46 |
40 /** | 47 /** |
41 * {@inheritdoc} | 48 * {@inheritdoc} |
42 */ | 49 */ |
43 public function authenticate($username, $password) { | 50 public function authenticate($username, $password) { |
44 $uid = FALSE; | 51 $uid = FALSE; |
45 | 52 |
46 if (!empty($username) && strlen($password) > 0) { | 53 if (!empty($username) && strlen($password) > 0) { |
47 $account_search = $this->entityManager->getStorage('user')->loadByProperties(['name' => $username]); | 54 $account_search = $this->entityTypeManager->getStorage('user')->loadByProperties(['name' => $username]); |
48 | 55 |
49 if ($account = reset($account_search)) { | 56 if ($account = reset($account_search)) { |
50 if ($this->passwordChecker->check($password, $account->getPassword())) { | 57 if ($this->passwordChecker->check($password, $account->getPassword())) { |
51 // Successful authentication. | 58 // Successful authentication. |
52 $uid = $account->id(); | 59 $uid = $account->id(); |