bookstack/app/Access/Controllers/HandlesPartialLogins.php

26 lines
580 B
PHP
Raw Normal View History

<?php
2023-05-18 00:56:55 +08:00
namespace BookStack\Access\Controllers;
2023-05-18 00:56:55 +08:00
use BookStack\Access\LoginService;
use BookStack\Exceptions\NotFoundException;
2023-05-18 00:56:55 +08:00
use BookStack\Users\Models\User;
trait HandlesPartialLogins
{
2021-08-02 22:04:43 +08: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 22:49:40 +08:00
}