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 --- .../src/Endpoints/Internal/Account/LoginRoute.cs | 37 ---------------------- 1 file changed, 37 deletions(-) delete mode 100644 server/src/Endpoints/Internal/Account/LoginRoute.cs (limited to 'server/src/Endpoints/Internal/Account/LoginRoute.cs') diff --git a/server/src/Endpoints/Internal/Account/LoginRoute.cs b/server/src/Endpoints/Internal/Account/LoginRoute.cs deleted file mode 100644 index 5b41c61..0000000 --- a/server/src/Endpoints/Internal/Account/LoginRoute.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -public class LoginRoute : RouteBaseAsync - .WithRequest - .WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// - public LoginRoute(AppDbContext context, UserService userService) { - _context = context; - _userService = userService; - } - - /// - /// Login a user. - /// - /// - /// - /// - [AllowAnonymous] - [HttpPost("~/_/account/login")] - public override async Task HandleAsync(LoginPayload request, CancellationToken cancellationToken = default) { - if (!ModelState.IsValid) { - return BadRequest(ModelState); - } - - var user = _context.Users.SingleOrDefault(u => u.Username == request.Username); - if (user == default || !user.VerifyPassword(request.Password)) { - return BadRequest(new ErrorResult("Invalid username or password")); - } - - await _userService.LogInUser(HttpContext, user, request.Persist); - return Ok(); - } -} -- cgit v1.3