+ $this->login($user, $method);
+ }
+
+ /**
+ * Get the last user that was attempted to be logged in.
+ * Only exists if the last login attempt had correct credentials
+ * but had been prevented by a secondary factor.
+ */
+ public function getLastLoginAttemptUser(): ?User
+ {
+ $id = session()->get(self::LAST_LOGIN_ATTEMPTED_SESSION_KEY);
+ if (!$id) {
+ return null;
+ }
+
+ return User::query()->where('id', '=', $id)->first();
+ }
+
+ /**
+ * Set the last login attempted user.
+ * Must be only used when credentials are correct and a login could be
+ * achieved but a secondary factor has stopped the login.
+ */
+ protected function setLastLoginAttemptedForUser(User $user)
+ {
+ session()->put(self::LAST_LOGIN_ATTEMPTED_SESSION_KEY, $user->id);
+ }
+
+ /**
+ * Clear the last login attempted session value.
+ */
+ protected function clearLastLoginAttempted(): void
+ {
+ session()->remove(self::LAST_LOGIN_ATTEMPTED_SESSION_KEY);