BookStack\Services\LdapService::validateUserCredentials PHP Method

validateUserCredentials() public method

public validateUserCredentials ( Illuminate\Contracts\Auth\Authenticatable $user, string $username, string $password ) : boolean
$user Illuminate\Contracts\Auth\Authenticatable
$username string
$password string
return boolean
    public function validateUserCredentials(Authenticatable $user, $username, $password)
    {
        $ldapUser = $this->getUserDetails($username);
        if ($ldapUser === null) {
            return false;
        }
        if ($ldapUser['uid'] !== $user->external_auth_id) {
            return false;
        }
        $ldapConnection = $this->getConnection();
        try {
            $ldapBind = $this->ldap->bind($ldapConnection, $ldapUser['dn'], $password);
        } catch (\ErrorException $e) {
            $ldapBind = false;
        }
        return $ldapBind;
    }

Usage Example

Esempio n. 1
0
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable $user
  * @param  array                                      $credentials
  * @return bool
  */
 public function validateCredentials(Authenticatable $user, array $credentials)
 {
     return $this->ldapService->validateUserCredentials($user, $credentials['username'], $credentials['password']);
 }