*/
protected $redirectTo = '/';
protected $redirectPath = '/';
- protected $redirectAfterLogout = '/';
- protected $socialAuthService;
- protected $loginService;
+ protected SocialAuthService $socialAuthService;
+ protected LoginService $loginService;
/**
* Create a new controller instance.
$this->loginService = $loginService;
$this->redirectPath = url('/');
- $this->redirectAfterLogout = url(config('auth.auto_redirect') ? '/login?logout=1' : '/');
}
public function username()
{
$socialDrivers = $this->socialAuthService->getActiveDrivers();
$authMethod = config('auth.method');
- $autoRedirect = config('auth.auto_redirect');
+ $preventInitiation = $request->get('prevent_auto_init') === 'true';
if ($request->has('email')) {
session()->flashInput([
// Store the previous location for redirect after login
$this->updateIntendedFromPrevious();
- if ($autoRedirect && !($request->has('logout') && $request->get('logout') == '1') && count($socialDrivers) == 0 && in_array($authMethod, ['oidc', 'saml2'])) {
- return view('auth.login-redirect', [
+ if (!$preventInitiation && $this->shouldAutoInitiate()) {
+ return view('auth.login-initiate', [
'authMethod' => $authMethod,
]);
}
redirect()->setIntendedUrl($previous);
}
+ /**
+ * Check if login auto-initiate should be valid based upon authentication config.
+ */
+ protected function shouldAutoInitiate(): bool
+ {
+ $socialDrivers = $this->socialAuthService->getActiveDrivers();
+ $authMethod = config('auth.method');
+ $autoRedirect = config('auth.auto_initiate');
+
+ return $autoRedirect && count($socialDrivers) === 0 && in_array($authMethod, ['oidc', 'saml2']);
+ }
+
/**
* Logout user and perform subsequent redirect.
*
{
$this->traitLogout($request);
- return redirect($this->redirectAfterLogout);
+ $redirectUri = $this->shouldAutoInitiate() ? '/login?prevent_auto_init=true' : '/';
+
+ return redirect($redirectUri);
}
}