public async Task <ActionResult> ResetPassword(ResetPassword formModel) { var userId = GetCookieValue(Request, StorefrontConstants.CustomerIdCookie); var token = GetCookieValue(Request, StorefrontConstants.PasswordResetTokenCookie); if (userId == null && token == null) { WorkContext.ErrorMessage = "Not enough info for reseting password"; return(View("error", WorkContext)); } var result = await _commerceCoreApi.StorefrontSecurityResetPasswordAsync(userId, token, formModel.Password); if (result.Succeeded == true) { // Remove cookies SetCookieValue(Response, StorefrontConstants.CustomerIdCookie); SetCookieValue(Response, StorefrontConstants.PasswordResetTokenCookie); return(View("customers/reset_password_confirmation", WorkContext)); } else { ModelState.AddModelError("form", result.Errors.First()); } return(View("customers/reset_password", WorkContext)); }
public async Task <ActionResult> ResetPassword(ResetPassword formModel) { var customerIdCookie = HttpContext.Request.Cookies[StorefrontConstants.CustomerIdCookie]; string userId = customerIdCookie != null ? customerIdCookie.Value : null; var tokenCookie = HttpContext.Request.Cookies[StorefrontConstants.PasswordResetTokenCookie]; string token = tokenCookie != null ? tokenCookie.Value : null; if (userId == null && token == null) { WorkContext.ErrorMessage = "Not enough info for reseting password"; return(View("error", WorkContext)); } var result = await _commerceCoreApi.StorefrontSecurityResetPasswordAsync(userId, token, formModel.Password); if (result.Succeeded == true) { HttpContext.Response.Cookies.Add(new HttpCookie(StorefrontConstants.CustomerIdCookie) { Expires = DateTime.UtcNow.AddDays(-1) }); HttpContext.Response.Cookies.Add(new HttpCookie(StorefrontConstants.PasswordResetTokenCookie) { Expires = DateTime.UtcNow.AddDays(-1) }); return(View("customers/reset_password_confirmation", WorkContext)); } else { ModelState.AddModelError("form", result.Errors.First()); } return(View("customers/reset_password", WorkContext)); }