maySignIn()) { return null; } if (! $user->active && $user->account_requested) { return __('Your account request has not been approved yet.'); } // Ahead of "deactivated", because the hourly sweep also switches // an expired account off — and "expired" is the reason its owner // can do something about, by asking for more time. return $user->hasExpired() ? __('Your account has expired.') : __('Your account has been deactivated.'); } /** * Phase 3 — start the session, or park the account for its second * factor. * * Returns true when a two-factor challenge is pending, in which case * no session has been created and the caller should redirect to * `two-factor.challenge`. * * Auth::login rather than Auth::attempt: the credential was already * verified upstream, and possibly not against a password at all. It * still fires the Login event, which is what writes the activity-log * entry. */ public function begin(User $user, bool $remember): bool { if ($user->hasTwoFactorEnabled()) { Session::put([ self::TWO_FACTOR_ID => $user->id, self::TWO_FACTOR_REMEMBER => $remember, ]); return true; } Auth::login($user, $remember); return false; } }