public bool InsertPassword(PasswordHistoryModel passwordHistoryModel) { passwordHistoryModel.CreatedTime = DateTime.Now; return(context.Execute("INSERT INTO PasswordHistory ([UserName],[Password],[CreatedTime]) VALUES(@Username,@Password,@CreatedTime)", new { Username = passwordHistoryModel.UserName, Password = passwordHistoryModel.Password, CreatedTime = passwordHistoryModel.CreatedTime }) == 1 ? true : false); }
// GET: PasswordHistory public ActionResult ChangePassword() { if (Session["UserLogon"] != null) { AccountModel acc = (AccountModel)Session["UserLogon"]; PasswordHistoryModel _model = new PasswordHistoryModel(); _model.UserName = acc.UserName; _model.UserID = acc.UserID; return(View(_model)); } else { return(RedirectToAction("Login", "Account")); } }
public bool IsRepeatingPassword(PasswordHistoryModel passwordHistory, int unUsablePasswordCount) { StringBuilder sbQuery = new StringBuilder(); sbQuery.Append("SELECT COUNT([Password]) FROM (SELECT TOP " + unUsablePasswordCount + " "); sbQuery.Append(" * FROM PasswordHistory WHERE UserName = @UserName ORDER BY CreateDate DESC) PWDHist WHERE Password = @Password"); var count = (context.ExecuteScalar(sbQuery.ToString(), new { PreviousPasswordsCount = unUsablePasswordCount, UserName = passwordHistory.UserName, Password = passwordHistory.Password })); int passwordCount = 0; int.TryParse(count.ToString(), out passwordCount); return(passwordCount > 0 ? true : false); }
public bool IsRepeatingPassword(PasswordHistoryModel passwordHistoryModel, out int unUsablePreviousPasswordCount) { int constValue = 0; int.TryParse(Constants.PortalSettingsKeyFallBackValues.UNUSABLEPREVIOUSPASSWORDSNUMBER, out constValue); unUsablePreviousPasswordCount = constValue; PortalSetting portalSetting = portalSettingsRepository.GetSettingByKey(Constants.PortalSettingsKeysConstants.UNUSABLEPREVIOUSPASSWORDSNUMBER); if (!string.IsNullOrWhiteSpace(portalSetting.Value)) { int.TryParse(portalSetting.Value, out unUsablePreviousPasswordCount); if (unUsablePreviousPasswordCount == 0) { unUsablePreviousPasswordCount = constValue; } } return(passwordHistoryRepository.IsRepeatingPassword(passwordHistoryModel, unUsablePreviousPasswordCount)); }
public ActionResult ChangeUserPassword(PasswordHistoryModel _model) { PasswordHistoryRequest request = new PasswordHistoryRequest { Data = new PasswordHistoryModel { UserID = _model.UserID, UserName = _model.UserName, Password = _model.Password, NewPassword = _model.NewPassword } }; PasswordHistoryResponse response = new PasswordHistoryResponse(); response = new PasswordHistoryValidator(_unitOfWork, _context).Validate(request); ViewBag.Response = $"{response.Status};{response.Message}"; return(View("ChangePassword")); }
public bool InsertPassword(PasswordHistoryModel passwordHistoryModel) { return(passwordHistoryRepository.InsertPassword(passwordHistoryModel)); }