123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Identity;
- using Microsoft.AspNetCore.Mvc;
- using MTWorkHR.Application.Filters;
- using MTWorkHR.Application.Identity;
- using MTWorkHR.Application.Models;
- using MTWorkHR.Core.Global;
- using MTWorkHR.Identity.Services;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- public class AuthController : ControllerBase
- {
- private readonly IAuthService _authenticationService;
- private readonly IUserService _userService;
- public AuthController(IAuthService authenticationService, IUserService userService)
- {
- _authenticationService = authenticationService;
- _userService = userService;
- }
- [HttpPost("login")]
- public async Task<ActionResult<AuthResponse>> Login(AuthRequest request)
- {
- return Ok( await _authenticationService.Login(request));
- }
- [HttpPost("register")]
- public async Task<ActionResult<UserDto>> Register([FromBody] UserDto input)
- {
- return await _userService.Create(input);
- }
-
- //[HttpPost("IsExpiredToken")]
- //[ProducesResponseType(StatusCodes.Status200OK)]
- //public async Task<bool> IsExpiredToken([FromBody] ForgetPasswordDto model)
- //{
- // return await _userService.IsExpiredToken(model);
- //}
- [HttpPost("forgetPasswordMail")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task ForgetPasswordMail(string userId)
- {
- await _userService.ForgetPasswordMail(userId);
- }
- [HttpPost("forgetPassword")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<bool> ForgetPassword([FromBody] ForgetPasswordDto model)
- {
- return await _userService.ForgetPassword(model);
- }
- [HttpGet("confirmEmail")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<bool> ConfirmEmail(ForgetPasswordDto model)
- {
- var result = await _userService.ConfirmEmail(model);
- return result;
- }
- }
- }
|