AuthController.cs 1.8 KB

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