From b7e39b59fd0fc7b5610ebff29035bf622079e0d8 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 5 Oct 2022 20:45:21 +0800 Subject: refactor: Change file structure --- server/src/Services/UserService.cs | 50 -------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 server/src/Services/UserService.cs (limited to 'server/src/Services/UserService.cs') diff --git a/server/src/Services/UserService.cs b/server/src/Services/UserService.cs deleted file mode 100644 index 6db663a..0000000 --- a/server/src/Services/UserService.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace IOL.GreatOffice.Api.Services; - -public class UserService -{ - private readonly 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), - }; - - 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; - } - - await httpContext.SignInAsync(principal, authenticationProperties); - await _passwordResetService.DeleteRequestsForUserAsync(user.Id); - } - - /// - /// Log out a user. - /// - /// - public async Task LogOutUser(HttpContext httpContext) { - await httpContext.SignOutAsync(); - } -} -- cgit v1.3