+
+ /**
+ * Check if the given credentials are likely for the system guest account.
+ */
+ protected function areCredentialsForGuest(array $credentials): bool
+ {
+ if (isset($credentials['email'])) {
+ return User::query()->where('email', '=', $credentials['email'])
+ ->where('system_name', '=', 'public')
+ ->exists();
+ }
+
+ return false;
+ }
+
+ /**
+ * Logs the current user out of the application.
+ * Returns an app post-redirect path.
+ */
+ public function logout(): string
+ {
+ auth()->logout();
+ session()->invalidate();
+ session()->regenerateToken();
+
+ return $this->shouldAutoInitiate() ? '/login?prevent_auto_init=true' : '/';
+ }
+
+ /**
+ * Check if login auto-initiate should be active based upon authentication config.
+ */
+ public function shouldAutoInitiate(): bool
+ {
+ $autoRedirect = config('auth.auto_initiate');
+ if (!$autoRedirect) {
+ return false;
+ }
+
+ $socialDrivers = $this->socialDriverManager->getActive();
+ $authMethod = config('auth.method');
+
+ return count($socialDrivers) === 0 && in_array($authMethod, ['oidc', 'saml2']);
+ }