Email Verification And Password Reset #8
@ -121,7 +121,7 @@ namespace qtc_api.Controllers
|
|||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("resend-email")]
|
[HttpPost("resend-verification-email")]
|
||||||
public async Task<ActionResult<ServiceResponse<bool>>> ResendVerificationEmail(string email)
|
public async Task<ActionResult<ServiceResponse<bool>>> ResendVerificationEmail(string email)
|
||||||
{
|
{
|
||||||
var user = await _userService.GetUserByEmail(email);
|
var user = await _userService.GetUserByEmail(email);
|
||||||
@ -156,7 +156,7 @@ namespace qtc_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("reset-password")]
|
[HttpPost("reset-password")]
|
||||||
public async Task<ActionResult<ServiceResponse<bool>>> ResetPassword(string confirmationToken, string password)
|
public async Task<ActionResult<ServiceResponse<bool>>> ResetPassword(UserPasswordResetDto request)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -165,7 +165,7 @@ namespace qtc_api.Controllers
|
|||||||
InboundClaimTypeMap = new Dictionary<string, string>()
|
InboundClaimTypeMap = new Dictionary<string, string>()
|
||||||
};
|
};
|
||||||
|
|
||||||
var jwt = handler.ReadJwtToken(confirmationToken);
|
var jwt = handler.ReadJwtToken(request.Token);
|
||||||
|
|
||||||
if (jwt != null)
|
if (jwt != null)
|
||||||
{
|
{
|
||||||
@ -181,7 +181,7 @@ namespace qtc_api.Controllers
|
|||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
if (user.Data.Email == email.Value && now < jwt.ValidTo.ToUniversalTime())
|
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();
|
await dataContext.SaveChangesAsync();
|
||||||
|
|
||||||
return Ok(new ServiceResponse<bool> { Success = true, Data = true });
|
return Ok(new ServiceResponse<bool> { Success = true, Data = true });
|
||||||
|
8
qtc-net-server/Dtos/User/UserPasswordResetDto.cs
Normal file
8
qtc-net-server/Dtos/User/UserPasswordResetDto.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user