Commit 8d6da5ed authored by Fabian de Rijk's avatar Fabian de Rijk
Browse files

Issue #3196456 by al_trottier: RuntimeException in LoginCallbackController

parent 6cfc7f00
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -4,11 +4,11 @@ namespace Drupal\o365_sso\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\externalauth\ExternalAuth;
use Drupal\o365\AuthenticationService;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\o365\GraphService;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;

/**
 * UserLoginController. Used when returned from the callback.
@@ -67,7 +67,7 @@ class UserLoginController extends ControllerBase {
  /**
   * Login a user.
   *
   * @return \Drupal\Core\Routing\TrustedRedirectResponse
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   The redirect to the set URL in config.
   *
   * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
@@ -112,16 +112,14 @@ class UserLoginController extends ControllerBase {
    }
    elseif ($account->isBlocked()) {
      $this->messenger()->addError(t('The requested account is blocked'));
      $response = new TrustedRedirectResponse('/user/login');
      return $response->send();
      return $this->redirect('user.login');
    }

    // Log the user in.
    $this->externalAuth->userLoginFinalize($account, $o365_id, 'o365_sso');

    // Return the redirect.
    $response = new TrustedRedirectResponse($redirectUrl);
    return $response->send();
    return new RedirectResponse($redirectUrl);
  }

}