protected function AuthController::processUserLogin in Auth0 Single Sign On 8
Same name and namespace in other branches
- 8.2 src/Controller/AuthController.php \Drupal\auth0\Controller\AuthController::processUserLogin()
Process the auth0 user profile and signin or signup the user.
1 call to AuthController::processUserLogin()
- AuthController::callback in src/
Controller/ AuthController.php - Handles the callback for the oauth transaction.
File
- src/
Controller/ AuthController.php, line 302
Class
- AuthController
- Controller routines for auth0 authentication.
Namespace
Drupal\auth0\ControllerCode
protected function processUserLogin(Request $request, $userInfo, $idToken) {
try {
$this
->validateUserEmail($userInfo);
} catch (EmailNotSetException $e) {
return $this
->failLogin(t('This account does not have an email associated. Please login with a different provider.'), 'No Email Found');
} catch (EmailNotVerifiedException $e) {
return $this
->auth0FailWithVerifyEmail($idToken);
}
// See if there is a user in the auth0_user table with the user info client id.
$user = $this
->findAuth0User($userInfo['user_id']);
if ($user) {
// User exists!
// update the auth0_user with the new userInfo object.
$this
->updateAuth0User($userInfo);
$event = new Auth0UserSigninEvent($user, $userInfo);
$this->eventDispatcher
->dispatch(Auth0UserSigninEvent::NAME, $event);
}
else {
try {
$user = $this
->signupUser($userInfo, $idToken);
} catch (EmailNotVerifiedException $e) {
return $this
->auth0FailWithVerifyEmail($idToken);
}
$this
->insertAuth0User($userInfo, $user
->id());
$event = new Auth0UserSignupEvent($user, $userInfo);
$this->eventDispatcher
->dispatch(Auth0UserSignupEvent::NAME, $event);
}
user_login_finalize($user);
if ($request->request
->has('destination')) {
return $this
->redirect($request->request
->get('destination'));
}
return $this
->redirect('entity.user.canonical', array(
'user' => $user
->id(),
));
}