Modify the process of password

The average user to change the password is to have a look at the steps.
Fill in the original password Dian a
two Dian fill in a new password and complete the password confirmation.
As shown below.
Here Insert Picture Description
When passwords are filled out you can go to the judge and then these passwords to the database to modify.
The first step in determining whether the data is complete. The new password and confirm the new password are the same. If not then it can not be modified. The following code

. var Ypassword = $ ( "# Ypassword") val (); // original code
var Xpassword = $ ( "# Xpassword ") val ();. // new password
var Qpassword = $ ( "# Qpassword ") val. ();//confirm password

IF (Ypassword == "" || Xpassword == "" || Qpassword == "") {
layer.alert ( "Please complete", {icon: 0, title : "! prompt"});
return;
}
IF (Xpassword = Qpassword!) {
layer.alert ( "your new password did not match, please re-enter!", {icon: 0, title: " Tip"});
}

The second step Dian determine whether the new password with the original password repeat, if repeated, please re-fill

IF (Ypassword == Xpassword) {
layer.alert ( "Your new password did not match, please re-enter!", {icon: 0, title: " Tip"});
}

When the condition submitted after the completion of all data is determined to modify the controller.
Data submitted here only need to submit 3, respectively, before the old password, the new password, single login user ID.
After the controller receives the data went with three queries, the user ID, password query, if the wrong password on Tip original password is not correct. If the modification is successful it clear landing Session.

try
{
var SelectP = (from tbUser in MyModels.S_User
where tbUser.UserID == UserID &&
tbUser.Password == Jpassword
select tbUser).Single();
SelectP.Password = password;
MyModels.Entry(SelectP).State = EntityState.Modified;
if (MyModels.SaveChanges() > 0)
{
strMsg = “修改成功”;
Session.Clear();
}
}
catch (Exception)
{
strMsg = “您输入的旧密码不存在!”;
}

If the modification is successful return to the page directly refresh the current page, because the controller to clear the session if a refresh will return to the login page.
if (Msg == "successfully modified") {
layer.alert (Msg, {icon:. 1, title: "prompt"}, function () {
location.reload ();
});

Guess you like

Origin blog.csdn.net/weixin_44486126/article/details/92760451