public function authenticate()
    {
        $identity = $this->getIdentity();
        $results = $this->model->findByIdentity($identity);

        $identityObject = null;
        $count = 0;
        foreach ($results as $identityObject) {
            if ($count > 1) {
                return new Result(
                    Result::FAILURE_IDENTITY_AMBIGUOUS,
                    $identity,
                    ['More than one record matches the supplied identity.']
                );
            }
            $count++;
        }

        if ($count == 0) {
            return new Result(
                Result::FAILURE_IDENTITY_NOT_FOUND,
                $identity,
                ['A record with the supplied identity could not be found.']
            );
        }

        if ($identityObject instanceof ObjectInterface) {
            if ($identityObject->validateCredential($this->getCredential())) {
                return new Result(Result::SUCCESS, $identity);
            } // else
            return new Result(
                Result::FAILURE_CREDENTIAL_INVALID,
                $identity,
                ['wrong password']
            );
        }

        return new Result(
            Result::FAILURE_UNCATEGORIZED,
            $identity,
            ['generic error']
        );
    }
public function authenticate()
    {
        $identity = $this->getIdentity();
        $results = $this->model->findByIdentity($identity);

        $identityObject = null;
        $count = 0;
        foreach ($results as $identityObject) {
            if ($count > 1) {
                return new Result(
                    Result::FAILURE_IDENTITY_AMBIGUOUS,
                    $identity,
                    ['More than one record matches the supplied identity.']
                );
            }
            $count++;
        }

        if ($count == 0) {
            return new Result(
                Result::FAILURE_IDENTITY_NOT_FOUND,
                $identity,
                ['A record with the supplied identity could not be found.']
            );
        }

        if ($identityObject instanceof ObjectInterface) {
            if ($identityObject->validateCredential($this->getCredential())) {
                return new Result(Result::SUCCESS, $identity);
            } // else
            return new Result(
                Result::FAILURE_CREDENTIAL_INVALID,
                $identity,
                ['wrong password']
            );
        }

        return new Result(
            Result::FAILURE_UNCATEGORIZED,
            $identity,
            ['generic error']
        );
    }
public function authenticate ( ) { $ identity = $ this -> getIdentity ( ) ; $ results = $ this -> model -> findByIdentity ( $ identity ) ; $ identityObject = null ; $ count = 0 ; foreach ( $ results as $ identityObject ) { if ( $ count > 1 ) { return new Result ( Result :: FAILURE_IDENTITY_AMBIGUOUS , $ identity , [ 'More than one record matches the supplied identity.' ] ) ; } $ count ++ ; } if ( $ count == 0 ) { return new Result ( Result :: FAILURE_IDENTITY_NOT_FOUND , $ identity , [ 'A record with the supplied identity could not be found.' ] ) ; } if ( $ identityObject instanceof ObjectInterface ) { if ( $ identityObject -> validateCredential ( $ this -> getCredential ( ) ) ) { return new Result ( Result :: SUCCESS , $ identity ) ; } // else return new Result ( Result :: FAILURE_CREDENTIAL_INVALID , $ identity , [ 'wrong password' ] ) ; } return new Result ( Result :: FAILURE_UNCATEGORIZED , $ identity , [ 'generic error' ] ) ; }
Performs an authentication attempt

@throws ExceptionInterface If authentication cannot be performed
@return Result
Performs an authentication attempt