AuthController.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. [HttpGet("forgetPasswordMail")]
  34. //[ProducesResponseType(StatusCodes.Status200OK)]
  35. public async Task<ActionResult<ForgetPasswordResponseDto>> ForgetPasswordMail([FromQuery] string email)
  36. {
  37. var result = await _userService.ForgetPasswordMail(email);
  38. return result;
  39. }
  40. [HttpPost("forgetPassword")]
  41. [ProducesResponseType(StatusCodes.Status200OK)]
  42. public async Task<ActionResult> ForgetPassword([FromBody] ForgetPasswordDto model)
  43. {
  44. return Ok( await _userService.ForgetPassword(model));
  45. }
  46. [HttpPost("VerifyOTP")]
  47. [ProducesResponseType(StatusCodes.Status200OK)]
  48. public async Task<ActionResult> VerifyOTP([FromBody] VerifyOTPDto model)
  49. {
  50. var result = await _userService.VerifyOTP(model);
  51. return Ok(result);
  52. }
  53. [HttpGet("confirmEmail")]
  54. [ProducesResponseType(StatusCodes.Status200OK)]
  55. public async Task<ActionResult> ConfirmEmail([FromQuery] ConfirmEmailDto model)
  56. {
  57. var result = await _userService.ConfirmEmail(model);
  58. return Ok(result);
  59. }
  60. }
  61. }