diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 17103e8..f36ad6d 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -26,14 +26,14 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I private static string GetFirstAuthCacheKey(string fingerprint) => $"{fingerprint}_auth_token_first"; private static string GetAttemptFailedCountKey(string fingerprint) => $"{fingerprint}_login_failed"; - private Task SetAuthTokenDataToCache(AuthToken data, CancellationToken cancellation) => + private Task StoreAuthTokenInCache(AuthToken data, CancellationToken cancellation) => cache.SetAsync( GetAuthCacheKey(data.Fingerprint), JsonSerializer.SerializeToUtf8Bytes(data), slidingExpiration: Lifetime, cancellationToken: cancellation); - private Task CreateFirstAuthTokenToCache(User data, RequestContextInfo requestContext, CancellationToken cancellation) => + private Task StoreFirstAuthTokenInCache(User data, RequestContextInfo requestContext, CancellationToken cancellation) => cache.SetAsync( GetFirstAuthCacheKey(requestContext.Fingerprint), JsonSerializer.SerializeToUtf8Bytes(new FirstAuthToken(requestContext) @@ -106,7 +106,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I AccessToken = token }; - await SetAuthTokenDataToCache(authToken, cancellation); + await StoreAuthTokenInCache(authToken, cancellation); cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn); cookieOptions.SetCookie(context, CookieNames.RefreshToken, authToken.RefreshToken, DateTime.UtcNow.Add(Lifetime)); @@ -126,7 +126,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I return TwoFactorAuthenticator.None; } - await CreateFirstAuthTokenToCache(user, requestContext, cancellation); + await StoreFirstAuthTokenInCache(user, requestContext, cancellation); return user.TwoFactorAuthenticator; } @@ -173,7 +173,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I return TwoFactorAuthenticator.None; } - await CreateFirstAuthTokenToCache(user, requestContext, cancellation); + await StoreFirstAuthTokenInCache(user, requestContext, cancellation); return user.TwoFactorAuthenticator; } @@ -211,7 +211,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I authToken.AccessToken = token; authToken.RefreshToken = newRefreshToken; - await SetAuthTokenDataToCache(authToken, cancellation); + await StoreAuthTokenInCache(authToken, cancellation); cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn); cookieOptions.SetCookie(context, CookieNames.RefreshToken, authToken.RefreshToken, DateTime.UtcNow.Add(Lifetime)); }