From 0725e4f7cf4c6f723264b6d461b91c660d144cb7 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 30 Oct 2022 22:40:03 +0700 Subject: feat: Apiwork --- code/api/src/Services/UserService.cs | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'code/api/src/Services/UserService.cs') diff --git a/code/api/src/Services/UserService.cs b/code/api/src/Services/UserService.cs index 6db663a..30231e8 100644 --- a/code/api/src/Services/UserService.cs +++ b/code/api/src/Services/UserService.cs @@ -2,49 +2,49 @@ namespace IOL.GreatOffice.Api.Services; public class UserService { - private readonly PasswordResetService _passwordResetService; + private readonly PasswordResetService _passwordResetService; - /// - /// Provides methods to perform common operations on user data. - /// - /// - public UserService(PasswordResetService passwordResetService) { - _passwordResetService = passwordResetService; - } + /// + /// Provides methods to perform common operations on user data. + /// + /// + public UserService(PasswordResetService passwordResetService) { + _passwordResetService = passwordResetService; + } - /// - /// Log in a user. - /// - /// - /// - /// - public async Task LogInUser(HttpContext httpContext, User user, bool persist = false) { - var claims = new List { - new(AppClaims.USER_ID, user.Id.ToString()), - new(AppClaims.NAME, user.Username), - }; + /// + /// Log in a user. + /// + /// + /// + /// + public async Task LogInUser(HttpContext httpContext, User user, bool persist = false) { + var claims = new List { + new(AppClaims.USER_ID, user.Id.ToString()), + new(AppClaims.NAME, user.Username), + }; - var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); - var principal = new ClaimsPrincipal(identity); - var authenticationProperties = new AuthenticationProperties { - AllowRefresh = true, - IssuedUtc = DateTimeOffset.UtcNow, - }; + var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); + var principal = new ClaimsPrincipal(identity); + var authenticationProperties = new AuthenticationProperties { + AllowRefresh = true, + IssuedUtc = DateTimeOffset.UtcNow, + }; - if (persist) { - authenticationProperties.ExpiresUtc = DateTimeOffset.UtcNow.AddMonths(6); - authenticationProperties.IsPersistent = true; - } + if (persist) { + authenticationProperties.ExpiresUtc = DateTimeOffset.UtcNow.AddMonths(6); + authenticationProperties.IsPersistent = true; + } - await httpContext.SignInAsync(principal, authenticationProperties); - await _passwordResetService.DeleteRequestsForUserAsync(user.Id); - } + await httpContext.SignInAsync(principal, authenticationProperties); + await _passwordResetService.DeleteRequestsForUserAsync(user.Id); + } - /// - /// Log out a user. - /// - /// - public async Task LogOutUser(HttpContext httpContext) { - await httpContext.SignOutAsync(); - } -} + /// + /// Log out a user. + /// + /// + public async Task LogOutUser(HttpContext httpContext) { + await httpContext.SignOutAsync(); + } +} \ No newline at end of file -- cgit v1.3