public ActionResult ResetPasswd(ResetPasswdViewModel model) { if (new Accounts().EmailExist(model.Email)) { string resetCode = Guid.NewGuid().ToString(); try { SendVerificationLinkEmail(model.Email, resetCode); Accounts account = new Accounts(); Users user = new Users(); user.Email = model.Email; var sessionInfo = account.SessionUserInfo(user); ResetPasswd info = new ResetPasswd() { Id = resetCode, UserId = sessionInfo.Id, ResetRequestDateTime = DateTime.Now }; if (account.AddResetPasswordLinkRecord(info)) { ModelState.AddModelError("", "Reset password link has been sent to your email id."); } } catch (Exception ex) { ModelState.AddModelError("", "Oops! Some Error Occured.\nPlease Try Again Later."); } } else { ModelState.AddModelError("", "Account Doesn't Exist!"); } return(View()); }
public bool ResetPasswdLink(ResetPasswd info) { try { db.ResetPassword.Add(info); db.SaveChanges(); return(true); } catch (Exception ex) { var ravenClient = new RavenClient("https://[email protected]/1820886"); ravenClient.Capture(new SentryEvent(ex)); return(false); } }
/// <summary> /// Update a record in Database for the Reset password Link sent to the user. /// </summary> /// <param name="info"></param> /// <returns>Flag as true if Added Successfully else false</returns> public bool AddResetPasswordLinkRecord(ResetPasswd info) { try { UserInformation user = new UserInformation(); if (user.ResetPasswdLink(info)) { return(true); } else { return(false); } } catch { return(false); } }