mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
26 lines
587 B
PHP
26 lines
587 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Controllers\Auth;
|
|
|
|
use BookStack\Auth\Access\LoginService;
|
|
use BookStack\Auth\User;
|
|
use BookStack\Exceptions\NotFoundException;
|
|
|
|
trait HandlesPartialLogins
|
|
{
|
|
/**
|
|
* @throws NotFoundException
|
|
*/
|
|
protected function currentOrLastAttemptedUser(): User
|
|
{
|
|
$loginService = app()->make(LoginService::class);
|
|
$user = auth()->user() ?? $loginService->getLastLoginAttemptUser();
|
|
|
|
if (!$user) {
|
|
throw new NotFoundException('A user for this action could not be found');
|
|
}
|
|
|
|
return $user;
|
|
}
|
|
}
|