From 269d976ad4af9074de366dc2316e3d51ec398177 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Wed, 25 Dec 2024 05:54:27 +0300 Subject: [PATCH] refactor: move arguments to a new line --- Security/Services/AuthService.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Security/Services/AuthService.cs b/Security/Services/AuthService.cs index 7909cc1..645e7c3 100644 --- a/Security/Services/AuthService.cs +++ b/Security/Services/AuthService.cs @@ -12,7 +12,8 @@ using System.Threading.Tasks; namespace Mirea.Api.Security.Services; -public class AuthService(ICacheService cache, IAccessToken accessTokenService, IRevokedToken revokedToken, ILogger logger, PasswordHashService passwordService) +public class AuthService(ICacheService cache, IAccessToken accessTokenService, IRevokedToken revokedToken, ILogger logger, + PasswordHashService passwordService) { public TimeSpan Lifetime { private get; init; } public TimeSpan LifetimeFirstAuth { private get; init; } @@ -93,7 +94,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I throw new SecurityException("Authentication failed. Please check your credentials."); } - private async Task GenerateAuthTokensAsync(CookieOptionsParameters cookieOptions, HttpContext context, RequestContextInfo requestContext, string userId, CancellationToken cancellation = default) + private async Task GenerateAuthTokensAsync(CookieOptionsParameters cookieOptions, HttpContext context, + RequestContextInfo requestContext, string userId, CancellationToken cancellation = default) { var refreshToken = GenerateRefreshToken(); var (token, expireIn) = GenerateAccessToken(userId); @@ -116,7 +118,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I authToken.Fingerprint); } - public async Task LoginOAuthAsync(CookieOptionsParameters cookieOptions, HttpContext context, User user, CancellationToken cancellation = default) + public async Task LoginOAuthAsync(CookieOptionsParameters cookieOptions, HttpContext context, User user, + CancellationToken cancellation = default) { var requestContext = new RequestContextInfo(context, cookieOptions); @@ -131,7 +134,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I return user.TwoFactorAuthenticator; } - public async Task LoginAsync(CookieOptionsParameters cookieOptions, HttpContext context, TwoFactorAuthenticator authenticator, string code, CancellationToken cancellation = default) + public async Task LoginAsync(CookieOptionsParameters cookieOptions, HttpContext context, TwoFactorAuthenticator authenticator, string code, + CancellationToken cancellation = default) { var requestContext = new RequestContextInfo(context, cookieOptions); @@ -159,7 +163,7 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I { await RecordFailedLoginAttempt(requestContext.Fingerprint, firstTokenAuth.UserId, cancellation); throw new SecurityException("Invalid verification code. Please try again."); - } + } await ResetFailedLoginAttempts(requestContext.Fingerprint, cancellation); } @@ -172,7 +176,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I return true; } - public async Task LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, string username, CancellationToken cancellation = default) + public async Task LoginAsync(CookieOptionsParameters cookieOptions, User user, HttpContext context, string password, + string username, CancellationToken cancellation = default) { var requestContext = new RequestContextInfo(context, cookieOptions); username = username.Trim(); @@ -210,8 +215,8 @@ public class AuthService(ICacheService cache, IAccessToken accessTokenService, I logger.LogWarning( error + "Cached refresh token {ExpectedRefreshToken} does not match the provided refresh token {RefreshToken}", - authToken.UserId, - authToken.Fingerprint, + authToken.UserId, + authToken.Fingerprint, authToken.RefreshToken, requestContext.RefreshToken); else