0

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?

halfpastfour.am
  • 5,764
  • 3
  • 44
  • 61
Keyur
  • 1,113
  • 1
  • 23
  • 42
  • Tell us something more about authentication service. Does it come from external module? Or it is standard Zend class? – SzymonM Mar 24 '17 at 15:04
  • @SzymonM It is a standard Zend class. The object of `Zend\Authentication\AuthenticationService` – Keyur Mar 27 '17 at 04:33

1 Answers1

0

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,
    ]
],
tasmaniski
  • 4,767
  • 3
  • 33
  • 65