refactor: rename methods to match the context
This commit is contained in:
parent
71c31c0bbb
commit
c12323dc29
@ -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 GetFirstAuthCacheKey(string fingerprint) => $"{fingerprint}_auth_token_first";
|
||||||
private static string GetAttemptFailedCountKey(string fingerprint) => $"{fingerprint}_login_failed";
|
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(
|
cache.SetAsync(
|
||||||
GetAuthCacheKey(data.Fingerprint),
|
GetAuthCacheKey(data.Fingerprint),
|
||||||
JsonSerializer.SerializeToUtf8Bytes(data),
|
JsonSerializer.SerializeToUtf8Bytes(data),
|
||||||
slidingExpiration: Lifetime,
|
slidingExpiration: Lifetime,
|
||||||
cancellationToken: cancellation);
|
cancellationToken: cancellation);
|
||||||
|
|
||||||
private Task CreateFirstAuthTokenToCache(User data, RequestContextInfo requestContext, CancellationToken cancellation) =>
|
private Task StoreFirstAuthTokenInCache(User data, RequestContextInfo requestContext, CancellationToken cancellation) =>
|
||||||
cache.SetAsync(
|
cache.SetAsync(
|
||||||
GetFirstAuthCacheKey(requestContext.Fingerprint),
|
GetFirstAuthCacheKey(requestContext.Fingerprint),
|
||||||
JsonSerializer.SerializeToUtf8Bytes(new FirstAuthToken(requestContext)
|
JsonSerializer.SerializeToUtf8Bytes(new FirstAuthToken(requestContext)
|
||||||
@ -106,7 +106,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
|
|||||||
AccessToken = token
|
AccessToken = token
|
||||||
};
|
};
|
||||||
|
|
||||||
await SetAuthTokenDataToCache(authToken, cancellation);
|
await StoreAuthTokenInCache(authToken, cancellation);
|
||||||
cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn);
|
cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn);
|
||||||
cookieOptions.SetCookie(context, CookieNames.RefreshToken, authToken.RefreshToken, DateTime.UtcNow.Add(Lifetime));
|
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;
|
return TwoFactorAuthenticator.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
await CreateFirstAuthTokenToCache(user, requestContext, cancellation);
|
await StoreFirstAuthTokenInCache(user, requestContext, cancellation);
|
||||||
|
|
||||||
return user.TwoFactorAuthenticator;
|
return user.TwoFactorAuthenticator;
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
|
|||||||
return TwoFactorAuthenticator.None;
|
return TwoFactorAuthenticator.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
await CreateFirstAuthTokenToCache(user, requestContext, cancellation);
|
await StoreFirstAuthTokenInCache(user, requestContext, cancellation);
|
||||||
|
|
||||||
return user.TwoFactorAuthenticator;
|
return user.TwoFactorAuthenticator;
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
|
|||||||
authToken.AccessToken = token;
|
authToken.AccessToken = token;
|
||||||
authToken.RefreshToken = newRefreshToken;
|
authToken.RefreshToken = newRefreshToken;
|
||||||
|
|
||||||
await SetAuthTokenDataToCache(authToken, cancellation);
|
await StoreAuthTokenInCache(authToken, cancellation);
|
||||||
cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn);
|
cookieOptions.SetCookie(context, CookieNames.AccessToken, authToken.AccessToken, expireIn);
|
||||||
cookieOptions.SetCookie(context, CookieNames.RefreshToken, authToken.RefreshToken, DateTime.UtcNow.Add(Lifetime));
|
cookieOptions.SetCookie(context, CookieNames.RefreshToken, authToken.RefreshToken, DateTime.UtcNow.Add(Lifetime));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user