/**
* {@inheritdoc}
*/
public function process(Request $request, $grantType = 'password')
{
$account = $this->records->getAccountByEmail($this->submittedForm->get('email')->getData());
if (!$account) {
return null;
}
$oauth = $this->records->getOauthByGuid($account->getGuid());
$requestPassword = $this->submittedForm->get('password')->getData();
if ($this->isValidPassword($oauth, $requestPassword) === false) {
return null;
}
$accessToken = $this->provider->getAccessToken('password', ['guid' => $account->getGuid()]);
$this->session->addAccessToken('local', $accessToken)->createAuthorisation($account->getGuid());
$request->query->set('code', Uuid::uuid4()->toString());
try {
parent::process($request, $grantType);
$this->finish($request);
$this->feedback->info('Login successful.');
} catch (DisabledAccountException $ex) {
$this->session->addRedirect($this->urlGenerator->generate('authenticationLogin'));
if ($this->session->getAuthorisation()) {
$this->dispatchEvent(MembersEvents::MEMBER_LOGIN_FAILED_ACCOUNT_DISABLED, $this->session->getAuthorisation());
}
}
return $this->session->popRedirect()->getResponse();
}