public ActionResult ResetPassword(string q) { SmartLibrary.Models.ResetPassword resetPasswordModel = new SmartLibrary.Models.ResetPassword(); if (!string.IsNullOrEmpty(q)) { try { string parameterString = EncryptionDecryption.DecryptByTripleDES(q); var parameters = parameterString.Split('#'); if (parameters != null && parameters.Count() == 2) { DateTime urlExpiredTime = DateTime.ParseExact(parameters[1], ProjectConfiguration.EmailDateTimeFormat, System.Globalization.CultureInfo.InvariantCulture); int id = parameters[0].ToInteger(); if (DateTime.Now > urlExpiredTime) { this.AddToastMessage(Resources.General.Error, Messages.UrlExpiredMessage, SystemEnumList.MessageBoxType.Error); return(this.RedirectToAction(Actions.Index, Controllers.Account)); } User user = this.userDataBL.GetUsersList(new User { Id = id }).FirstOrDefault(); if (user != null && user.Id > 0) { resetPasswordModel.Id = user.Id; } else { this.AddToastMessage(Resources.General.Error, Messages.UserAccountNotmatched, SystemEnumList.MessageBoxType.Error); return(this.RedirectToAction(Actions.Index, Controllers.Account)); } } else { this.AddToastMessage(Resources.General.Error, Messages.InvalidUrlMessage, SystemEnumList.MessageBoxType.Error); return(this.RedirectToAction(Actions.Index, Controllers.Account)); } } catch (Exception) { return(this.RedirectToAction(Actions.Index, Controllers.Account)); } } else { this.ViewBag.ResetPasswordMessage = Messages.InvalidUrlMessage; return(this.RedirectToAction(Actions.Index, Controllers.Account)); } return(this.View(Views.ResetPassword, resetPasswordModel)); }
public ActionResult ResetPassword(SmartLibrary.Models.ResetPassword resetPassword) { if (resetPassword == null || ConvertTo.ToInteger(resetPassword.Id) <= 0) { this.AddToastMessage(Resources.General.Error, Account.UserNotExist, SystemEnumList.MessageBoxType.Error); return(this.View(Views.ResetPassword, resetPassword)); } if (resetPassword.NewPassword != resetPassword.ConfirmPassword) { this.AddToastMessage(Resources.General.Error, Account.NewPasswordAndConfirmPasswordNotMatch, SystemEnumList.MessageBoxType.Error); return(this.View(Views.ResetPassword, resetPassword)); } var userModel = this.userDataBL.GetUsersList(new User() { Id = resetPassword.Id }).FirstOrDefault(); if (userModel != null && userModel.Id > 0) { userModel.Password = EncryptionDecryption.EncryptByTripleDES(resetPassword.NewPassword); bool response = this.commonBL.ChangePassword(userModel.Id, userModel.Password, Infrastructure.SystemEnumList.ChangePasswordFor.User.GetDescription()); if (response) { this.AddToastMessage(Resources.General.Success, Account.PasswordChangedSuccessfully, Infrastructure.SystemEnumList.MessageBoxType.Success); return(new RedirectResult(this.Url.Action(Views.Index, Controllers.Account))); } else { this.AddToastMessage(Resources.General.Error, Messages.ChangePasswordError, Infrastructure.SystemEnumList.MessageBoxType.Error); return(this.View(Views.ResetPassword, resetPassword)); } } else { this.AddToastMessage(Resources.General.Error, Account.UserNotExist, Infrastructure.SystemEnumList.MessageBoxType.Error); return(this.View(Views.ResetPassword, resetPassword)); } }