Send Password Reset Over DTO Instead Of Parameters

This commit is contained in:
Alan Moon 2025-07-27 13:54:58 -07:00
parent 3a530b6639
commit ae60f58107
2 changed files with 12 additions and 4 deletions

View File

@ -121,7 +121,7 @@ namespace qtc_api.Controllers
return Ok(response);
}
[HttpPost("resend-email")]
[HttpPost("resend-verification-email")]
public async Task<ActionResult<ServiceResponse<bool>>> ResendVerificationEmail(string email)
{
var user = await _userService.GetUserByEmail(email);
@ -156,7 +156,7 @@ namespace qtc_api.Controllers
}
[HttpPost("reset-password")]
public async Task<ActionResult<ServiceResponse<bool>>> ResetPassword(string confirmationToken, string password)
public async Task<ActionResult<ServiceResponse<bool>>> ResetPassword(UserPasswordResetDto request)
{
try
{
@ -165,7 +165,7 @@ namespace qtc_api.Controllers
InboundClaimTypeMap = new Dictionary<string, string>()
};
var jwt = handler.ReadJwtToken(confirmationToken);
var jwt = handler.ReadJwtToken(request.Token);
if (jwt != null)
{
@ -181,7 +181,7 @@ namespace qtc_api.Controllers
var now = DateTime.UtcNow;
if (user.Data.Email == email.Value && now < jwt.ValidTo.ToUniversalTime())
{
user.Data.PasswordHash = BCrypt.Net.BCrypt.HashPassword(password);
user.Data.PasswordHash = BCrypt.Net.BCrypt.HashPassword(request.Password);
await dataContext.SaveChangesAsync();
return Ok(new ServiceResponse<bool> { Success = true, Data = true });

View File

@ -0,0 +1,8 @@
namespace qtc_api.Dtos.User
{
public class UserPasswordResetDto
{
public string Token { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
}
}