]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/Auth/HandlesPartialLogins.php
f9bacb95d85e9eaaaff7a585ab2a3555e0adc3ec
[bookstack] / app / Http / Controllers / Auth / HandlesPartialLogins.php
1 <?php
2
3 namespace BookStack\Http\Controllers\Auth;
4
5 use BookStack\Auth\Access\LoginService;
6 use BookStack\Auth\User;
7 use BookStack\Exceptions\NotFoundException;
8
9 trait HandlesPartialLogins
10 {
11     protected function currentOrLastAttemptedUser(): User
12     {
13         $loginService = app()->make(LoginService::class);
14         $user = auth()->user() ?? $loginService->getLastLoginAttemptUser();
15
16         if (!$user) {
17             throw new NotFoundException('A user for this action could not be found');
18         }
19
20         return $user;
21     }
22 }