2021-07-18 23:52:31 +08:00
|
|
|
<?php
|
|
|
|
|
2023-05-18 00:56:55 +08:00
|
|
|
namespace BookStack\Access\Controllers;
|
2021-07-18 23:52:31 +08:00
|
|
|
|
2023-05-18 00:56:55 +08:00
|
|
|
use BookStack\Access\LoginService;
|
2021-07-18 23:52:31 +08:00
|
|
|
use BookStack\Exceptions\NotFoundException;
|
2023-05-18 00:56:55 +08:00
|
|
|
use BookStack\Users\Models\User;
|
2021-07-18 23:52:31 +08:00
|
|
|
|
|
|
|
trait HandlesPartialLogins
|
|
|
|
{
|
2021-08-02 22:04:43 +08:00
|
|
|
/**
|
|
|
|
* @throws NotFoundException
|
|
|
|
*/
|
2021-07-18 23:52:31 +08:00
|
|
|
protected function currentOrLastAttemptedUser(): User
|
|
|
|
{
|
|
|
|
$loginService = app()->make(LoginService::class);
|
|
|
|
$user = auth()->user() ?? $loginService->getLastLoginAttemptUser();
|
|
|
|
|
|
|
|
if (!$user) {
|
2024-05-21 00:23:15 +08:00
|
|
|
throw new NotFoundException(trans('errors.login_user_not_found'));
|
2021-07-18 23:52:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
}
|
2021-08-21 22:49:40 +08:00
|
|
|
}
|