From 25b6c7d69148c04d9a37abc4250fdceb6a2bc31a Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Wed, 29 May 2024 06:00:15 +0300 Subject: [PATCH] feat: add method if there is no pre-auth token --- Security/Services/AuthService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 58d439b..5426532 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -31,10 +31,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I private Task RevokeAccessToken(string token) => revokedToken.AddTokenToRevokedAsync(token, accessTokenService.GetExpireDateTime(token)); - public async Task GenerateAuthTokensAsync(TokenRequest request, string preAuthToken, CancellationToken cancellation = default) + public async Task GenerateAuthTokensAsync(TokenRequest request, string userId, CancellationToken cancellation = default) { - string userId = await new PreAuthService(cache).MatchToken(request, preAuthToken, cancellation); - var refreshToken = GenerateRefreshToken(); var accessToken = GenerateAccessToken(userId); @@ -58,6 +56,12 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I }; } + public async Task GenerateAuthTokensWithPreAuthAsync(TokenRequest request, string preAuthToken, + CancellationToken cancellation = default) => + await GenerateAuthTokensAsync(request, + await new PreAuthService(cache).MatchToken(request, preAuthToken, cancellation), + cancellation); + public async Task RefreshTokenAsync(TokenRequest request, string refreshToken, CancellationToken cancellation = default) { var authToken = await cache.GetAsync(GetAuthCacheKey(request.Fingerprint), cancellation)