public function loginAttempt($username, Password $password)
    {
        $userData = $this->storage->getUserByName($username);
        $encoder = $this->getPasswordEncoder($userData);

        $dummy = bin2hex(\random_bytes(32));
        $dummyHash = $encoder->encode($dummy);

        if (!$userData) {
            // The user doesn't exist, dummy call is performed to prevent time analysis
            $encoder->isValid($dummyHash, $password);
            return false;
        }
        
        return $encoder->isValid($userData['pwhash'], $password->get());
    }
public function loginAttempt($username, Password $password)
    {
        $userData = $this->storage->getUserByName($username);
        $encoder = $this->getPasswordEncoder($userData);

        $dummy = bin2hex(\random_bytes(32));
        $dummyHash = $encoder->encode($dummy);

        if (!$userData) {
            // The user doesn't exist, dummy call is performed to prevent time analysis
            $encoder->isValid($dummyHash, $password);
            return false;
        }
        
        return $encoder->isValid($userData['pwhash'], $password->get());
    }
public function loginAttempt ( $ username , Password $ password ) { $ userData = $ this -> storage -> getUserByName ( $ username ) ; $ encoder = $ this -> getPasswordEncoder ( $ userData ) ; $ dummy = bin2hex ( \ random_bytes ( 32 ) ) ; $ dummyHash = $ encoder -> encode ( $ dummy ) ; if ( ! $ userData ) { // The user doesn't exist, dummy call is performed to prevent time analysis $ encoder -> isValid ( $ dummyHash , $ password ) ; return false ; } return $ encoder -> isValid ( $ userData [ 'pwhash' ] , $ password -> get ( ) ) ; }
Attempt a login with the specified credentials

@param string $username Username
@param Password $password Password
@return bool Whether login was successful
Attempt a login with the specified credentials