AuthController.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Identity;
  3. using Microsoft.AspNetCore.Mvc;
  4. using MTWorkHR.Application.Filters;
  5. using MTWorkHR.Application.Identity;
  6. using MTWorkHR.Application.Models;
  7. using MTWorkHR.Core.Global;
  8. using MTWorkHR.Identity.Services;
  9. namespace MTWorkHR.API.Controllers
  10. {
  11. [Route("api/[controller]")]
  12. [ApiController]
  13. public class AuthController : ControllerBase
  14. {
  15. private readonly IAuthService _authenticationService;
  16. private readonly IUserService _userService;
  17. public AuthController(IAuthService authenticationService, IUserService userService)
  18. {
  19. _authenticationService = authenticationService;
  20. _userService = userService;
  21. }
  22. [HttpPost("login")]
  23. public async Task<ActionResult<AuthResponse>> Login(AuthRequest request)
  24. {
  25. return Ok( await _authenticationService.Login(request));
  26. }
  27. [HttpPost("register")]
  28. [Consumes("multipart/form-data")]
  29. public async Task<ActionResult<UserDto>> Register([FromForm] UserDto input)
  30. {
  31. return await _userService.Create(input);
  32. }
  33. //[HttpPost("IsExpiredToken")]
  34. //[ProducesResponseType(StatusCodes.Status200OK)]
  35. //public async Task<bool> IsExpiredToken([FromBody] ForgetPasswordDto model)
  36. //{
  37. // return await _userService.IsExpiredToken(model);
  38. //}
  39. [HttpGet("forgetPasswordMail")]
  40. //[ProducesResponseType(StatusCodes.Status200OK)]
  41. public async Task<string> ForgetPasswordMail(string email)
  42. {
  43. return await _userService.ForgetPasswordMail(email);
  44. }
  45. [HttpPost("forgetPassword")]
  46. [ProducesResponseType(StatusCodes.Status200OK)]
  47. public async Task<bool> ForgetPassword([FromBody] ForgetPasswordDto model)
  48. {
  49. return await _userService.ForgetPassword(model);
  50. }
  51. [HttpGet("confirmEmail")]
  52. [ProducesResponseType(StatusCodes.Status200OK)]
  53. public async Task<bool> ConfirmEmail([FromQuery] ForgetPasswordDto model)
  54. {
  55. var result = await _userService.ConfirmEmail(model);
  56. return result;
  57. }
  58. }
  59. }