Exception while calling authenticate method of Zend Authentication Service

287 Views Asked by At

I'm migrating my ZF2 app to ZF3.

While calling the authenticate method, getting this exception

An error occurred An error occurred during execution; please try again later. No Exception available

This is how I' calling the method,

public function __construct($authService, $sessionManager, $config)
{
    $this->authService = $authService;//Getting the Zend\Authentication\AuthenticationService object (no error here)
    $this->sessionManager = $sessionManager;
    $this->config = $config;
}
public function login($email, $password, $rememberMe)
{
    if ($this->authService->getIdentity() != null) {
        throw new \Exception('Already logged in');
    }

    // Authenticate with login/password.
    $authAdapter = $this->authService->getAdapter();
    $authAdapter->setEmail($email);//abc.gmail.com
    $authAdapter->setPassword($password);//sha1 password
    $this->authService->authenticate();//Exception is generating here
}

What is I'm doing wrong?

1

There are 1 best solutions below

0
tasmaniski On

Your exception message is not enough, you should check php_error.log for details.

I assume that you are not registered Auth Service in the config.

So in config/autoload/global.php add

'service_manager' => [
    'invokables' => [
        Zend\Authentication\AuthenticationService::class => Zend\Authentication\AuthenticationService::class,
    ]
],