Add Application configuration #11

Merged
Wesser merged 128 commits from feat/add-setup into release/v1.0.0 2024-06-01 07:35:30 +03:00
Showing only changes of commit f4ad1518ef - Show all commits

View File

@ -17,26 +17,28 @@ public class PreAuthService(ICacheService cache)
GeneratorKey.GenerateString(16); GeneratorKey.GenerateString(16);
private static string GetPreAuthCacheKey(string fingerprint) => $"{fingerprint}_pre_auth_token"; private static string GetPreAuthCacheKey(string fingerprint) => $"{fingerprint}_pre_auth_token";
{
var firstAuthToken = GenerateFirstAuthToken();
var loginStructure = new PreAuthToken public async Task<PreAuthTokenResponse> GeneratePreAuthTokenAsync(TokenRequest request, string userId, CancellationToken cancellation = default)
{
var preAuthToken = GeneratePreAuthToken();
var preAuthTokenStruct = new PreAuthToken
{ {
Fingerprint = request.Fingerprint, Fingerprint = request.Fingerprint,
UserId = userId, UserId = userId,
UserAgent = request.UserAgent, UserAgent = request.UserAgent,
Token = firstAuthToken Token = preAuthToken
}; };
await cache.SetAsync( await cache.SetAsync(
GetPreAuthCacheKey(request.Fingerprint), GetPreAuthCacheKey(request.Fingerprint),
JsonSerializer.SerializeToUtf8Bytes(loginStructure), JsonSerializer.SerializeToUtf8Bytes(preAuthTokenStruct),
Lifetime, Lifetime,
cancellation); cancellation);
return new PreAuthTokenResponse return new PreAuthTokenResponse
{ {
Token = firstAuthToken, Token = preAuthToken,
ExpiresIn = DateTime.UtcNow.Add(Lifetime) ExpiresIn = DateTime.UtcNow.Add(Lifetime)
}; };
} }