Webiny\Component\Security\User\Providers\Memory\User::authenticate PHP Method

authenticate() public method

This method verifies the credentials of current user with the credentials provided from the Login object.
public authenticate ( Login $login, Firewall $firewall ) : boolean
$login Webiny\Component\Security\Authentication\Providers\Login
$firewall Webiny\Component\Security\Authentication\Firewall
return boolean Return true if credentials are valid, otherwise return false.
    public function authenticate(Login $login, Firewall $firewall)
    {
        try {
            $result = $firewall->verifyPasswordHash($login->getPassword(), $this->getPassword());
        } catch (\Exception $e) {
            throw new MemoryException($e->getMessage());
        }
        return $result;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param Firewall $firewall
  *
  * @dataProvider firewallProvider
  */
 public function testAuthenticateFalse($firewall)
 {
     $user = new User();
     $user->populate('kent', 'batman', [new Role('ROLE_SUPERHERO')]);
     $login = new Login('kent', 'superman');
     $this->assertFalse($user->authenticate($login, $firewall));
 }