Files
BookStack/app/Access/Controllers/HandlesPartialLogins.php

26 lines
580 B
PHP
Raw Normal View History

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