refactor: return next step from security

This commit is contained in:
2024-11-02 01:06:58 +03:00
parent 61dc0a8bc4
commit 3811d879ab
2 changed files with 5 additions and 4 deletions

View File

@ -121,7 +121,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
return true;
}
public async Task<bool> LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, CancellationToken cancellation = default)
public async Task<TwoFactorAuthenticator> LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, CancellationToken cancellation = default)
{
var requestContext = new RequestContextInfo(context, cookieOptions);
@ -130,7 +130,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
if (user.TwoFactorAuthenticator == TwoFactorAuthenticator.None)
{
await GenerateAuthTokensAsync(cookieOptions, context, requestContext, user.Id.ToString(), cancellation);
return true;
return TwoFactorAuthenticator.None;
}
var firstAuthToken = new FirstAuthToken(requestContext)
@ -142,7 +142,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I
await cache.SetAsync(GetFirstAuthCacheKey(requestContext.Fingerprint), firstAuthToken, absoluteExpirationRelativeToNow: LifetimeFirstAuth, cancellationToken: cancellation);
return false;
return user.TwoFactorAuthenticator;
}
public async Task RefreshTokenAsync(CookieOptionsParameters cookieOptions, HttpContext context, CancellationToken cancellation = default)