public async Task <IActionResult> Activate([FromBody] PasswordResetViewmodel model) { try { model.UserId = Uri.UnescapeDataString(model.UserId); model.Code = Uri.UnescapeDataString(model.Code); var currentUser = await context.Users.FirstOrDefaultAsync(x => x.Id == model.UserId); if (currentUser == null) { return(NotFound(new { message = "User not found" })); } var result = await userManager.ConfirmEmailAsync(currentUser, model.Code); if (!result.Succeeded) { return(BadRequest(new { message = result.Errors.FirstOrDefault().Description })); } return(Ok()); } catch (Exception ex) { _logger.LogError("Unable to activate your account.", ex); return(BadRequest(ex.ToString())); } }
public async Task <IActionResult> ResetPassword(PasswordResetViewmodel passwordResetModel) { var model = _mapper.Map <PasswordResetModel>(passwordResetModel); var result = await _identityService.ResetPassword(model); if (result.Succeeded) { return(NoContent()); } return(BadRequest(result.Errors)); }