public function processLogin($authProvider = '')
{
try {
// if we are on login page, first try to get the instance of Login object from current auth provider
$login = $this->getAuthProvider($authProvider)->getLoginObject($this->getConfig());
if (!$this->isInstanceOf($login, 'Webiny\\Component\\Security\\Authentication\\Providers\\Login')) {
throw new FirewallException('Authentication provider method getLoginObject() must return an instance of
"Webiny\\Component\\Security\\Authentication\\Providers\\Login".');
}
$login->setAuthProviderName($this->authProviderName);
} catch (\Exception $e) {
throw new FirewallException($e->getMessage());
}
// forward the login object to user providers and validate the credentials
$this->user = $this->authenticate($login);
if (!$this->user) {
// login failed
$this->getAuthProvider($authProvider)->invalidLoginProvidedCallback();
$this->eventManager()->fire(SecurityEvent::LOGIN_INVALID, new SecurityEvent(new AnonymousUser()));
return false;
} else {
$this->getAuthProvider($authProvider)->loginSuccessfulCallback($this->user);
$this->eventManager()->fire(SecurityEvent::LOGIN_VALID, new SecurityEvent($this->user));
$this->setUserRoles();
$this->userAuthenticated = true;
return true;
}
}