Ejemplo n.º 1
0
        public ActionResult RestorePasswordState(int passwordChangeId)
        {
            PasswordChange passwordChange = dbContext.GetPasswordChange(passwordChangeId);
            PasswordModel  oldPassword;
            PasswordModel  newPassword;

            if (String.IsNullOrEmpty(passwordChange.OldData))
            {
                newPassword = PasswordChange.StringToPassword(passwordChange.NewData);
                oldPassword = dbContext.GetPassword(passwordChange.PasswordId);
            }
            else if (String.IsNullOrEmpty(passwordChange.NewData))
            {
                newPassword = PasswordChange.StringToPassword(passwordChange.OldData);
                oldPassword = dbContext.GetPassword(passwordChange.PasswordId);
            }
            else
            {
                newPassword = PasswordChange.StringToPassword(passwordChange.OldData);
                oldPassword = PasswordChange.StringToPassword(passwordChange.NewData);
            }

            dbContext.UpdatePassword(newPassword);

            PasswordChange.LogPasswordEdit(oldPassword, newPassword, dbContext);

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id, PasswordModel password)
        {
            UserInfo userInfo = GetUserInfo();

            password.PasswordHash =
                EncryptionHelper.EncryptPasswordAES(
                    password.PasswordHash,
                    userInfo.LoggedUserPassword);

            PasswordChange.LogPasswordEdit(
                dbContext.GetPassword(password.Id),
                password,
                dbContext);

            dbContext.UpdatePassword(password);
            ActivityLog.Log(userInfo.Id, ActionType.UpdatePassword, dbContext);

            return(RedirectToAction(nameof(Index)));
        }