- Fixed a bug where given entity would failed it's loading with an error

This commit is contained in:
Dave M. 2023-12-12 18:57:03 -05:00
parent 70daae93f5
commit 0657622eab
2 changed files with 8 additions and 3 deletions

View File

@ -27,8 +27,13 @@ class Authenticate {
public function rememberMe() : ? UserInterface public function rememberMe() : ? UserInterface
{ {
$logUser = function(? int $id) { $logUser = function(? int $id) {
if ( $id === null || null === ( $user = $this->user::repository()->loadFromPk($id) ) ) { try {
throw new \InvalidArgumentException(sprintf("User having id '%s' was not found.", $id)); if ($id === null || null === ($user = $this->user::repository()->loadFromPk($id))) {
throw new \InvalidArgumentException(sprintf("User having id '%s' was not found.", $id));
}
}
catch(\Exception $ex) {
return null;
} }
$this->user->fromArray($user); $this->user->fromArray($user);

View File

@ -21,7 +21,7 @@ class PostRequestAuthenticationMiddleware implements MiddlewareInterface
protected \Closure $loginFailedResponse, protected \Closure $loginFailedResponse,
PostRequestAuthentication $authenticator = null, PostRequestAuthentication $authenticator = null,
) { ) {
$this->authenticator = $authenticator ?: new PostRequestAuthentication(new Authenticate()); $this->authenticator = $authenticator ?: new PostRequestAuthentication(new Authenticate($entity));
} }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface