summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/user/src/UserAuthenticationInterface.php
blob: 34f7fe9cb99a25102a5a0718f67478e92179ecc7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

namespace Drupal\user;

/**
 * An interface for validating user authentication credentials.
 */
interface UserAuthenticationInterface {

  /**
   * Validates user authentication credentials.
   *
   * @param string $identifier
   *   The user identifier to authenticate. Usually the username.
   *
   * @return Drupal\User\UserInterface|false
   *   The user account on success, or FALSE on failure to authenticate.
   */
  public function lookupAccount($identifier): UserInterface|false;

  /**
   * Validates user authentication credentials for an account.
   *
   * This can be used where the account has already been located using the login
   * credentials.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The account to authenticate.
   * @param string $password
   *   A plain-text password, such as trimmed text from form values.
   *
   * @return bool
   *   TRUE on success, FALSE on failure.
   */
  public function authenticateAccount(UserInterface $account, #[\SensitiveParameter] string $password): bool;

}