You are here

private function AuthController::checkForError in Auth0 Single Sign On 8.2

Check for errors.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

string $returnTo: The return url.

Return value

\Drupal\Core\Routing\TrustedRedirectResponse|RedirectResponse|null The redirect response.

1 call to AuthController::checkForError()
AuthController::callback in src/Controller/AuthController.php
Handles the callback for the oauth transaction.

File

src/Controller/AuthController.php, line 383
Contains \Drupal\auth0\Controller\AuthController.

Class

AuthController
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Controller

Code

private function checkForError(Request $request, $returnTo) {
  $error_msg = $this
    ->t('There was a problem logging you in');

  // Check for in URL parameters and REQUEST.
  $error_code = $request->query
    ->get('error', $request->request
    ->get('error'));

  // Errors codes that should be redirected back to Auth0 for authentication.
  $redirect_errors = [
    'login_required',
    'interaction_required',
    'consent_required',
  ];
  if ($error_code && in_array($error_code, $redirect_errors)) {
    return new TrustedRedirectResponse($this
      ->buildAuthorizeUrl(FALSE, $returnTo));
  }
  elseif ($error_code) {
    $error_desc = $request->query
      ->get('error_description', $request->request
      ->get('error_description', $error_code));
    return $this
      ->failLogin($error_msg . ':  ' . $error_desc, $error_desc);
  }
  return NULL;
}