public void InitUserPasswordReset(InitPasswordResetModel model) { var userData = userDataRepository.FetchAll().Where(x => x.UserEmail == model.UserEmail).FirstOrDefault(); userServiceValidationHelper.ValidateUserData(userData); string token = hashCryptoHelper.HashString(model.UserEmail); int expirationMins = optionManager.CurrentValue.AppSettings.PasswordResetExpirationInMin; userData.IsTokenUsed = false; userData.TokenExpirationTime = DateTime.Now.AddMinutes(expirationMins); userData.TokenHash = token; userDataRepository.Update(userData); userDataRepository.Save(); string from = optionManager.CurrentValue.SmtpSettings.Sender; string to = model.UserEmail; string subject = Resource.MessageSubject_PasswordReset; string body = string.Format(Resource.MessageTemplate_PasswordReset, token); var message = new MailMessage(from, to, subject, body); message.IsBodyHtml = true; messageService.SendEmail(message); }
public IActionResult InitPasswordReset([FromBody] InitPasswordResetModel model) { userLoginService.InitUserPasswordReset(model); return(Ok()); }