diff --git a/app/Services/OAuth2/TokenService.php b/app/Services/OAuth2/TokenService.php index 5ac3c849..9f3975da 100644 --- a/app/Services/OAuth2/TokenService.php +++ b/app/Services/OAuth2/TokenService.php @@ -1436,7 +1436,13 @@ final class TokenService implements ITokenService $user = $this->auth_service->getCurrentUser(); - if(!$user) + if(is_null($user)){ + $user_id = $this->principal_service->get()->getUserId(); + Log::debug(sprintf("user id is %s", $user_id)); + $user = $this->auth_service->getUserById($user_id); + } + + if(is_null($user)) throw new AbsentCurrentUserException; // build claim set diff --git a/app/libs/OAuth2/GrantTypes/AuthorizationCodeGrantType.php b/app/libs/OAuth2/GrantTypes/AuthorizationCodeGrantType.php index dc574df4..f2059443 100644 --- a/app/libs/OAuth2/GrantTypes/AuthorizationCodeGrantType.php +++ b/app/libs/OAuth2/GrantTypes/AuthorizationCodeGrantType.php @@ -250,6 +250,12 @@ class AuthorizationCodeGrantType extends InteractiveGrantType throw new UriNotAllowedException($current_redirect_uri); } + $this->principal_service->register + ( + $auth_code->getUserId(), + $auth_code->getAuthTime() + ); + $response = OAuth2AccessTokenResponseFactory::build ( $this->token_service,