changing password in settings dialog

This commit is contained in:
azivner
2017-09-12 22:23:57 -04:00
parent b0957a0c8f
commit 3e97cdf085
3 changed files with 48 additions and 6 deletions

View File

@@ -8,7 +8,37 @@ function displaySettings() {
}
$("#changePasswordForm").submit(() => {
console.log("Submit");
const oldPassword = $("#oldPassword").val();
const newPassword1 = $("#newPassword1").val();
const newPassword2 = $("#newPassword2").val();
$("#oldPassword").val('');
$("#newPassword1").val('');
$("#newPassword2").val('');
if (newPassword1 != newPassword2) {
alert("New passwords are not the same.");
return false;
}
$.ajax({
url: baseUrl + 'password/change',
type: 'POST',
data: JSON.stringify({
'current_password': oldPassword,
'new_password': newPassword1
}),
contentType: "application/json",
success: function (result) {
if (result.success) {
alert("Password has been changed.");
}
else {
alert(result.message);
}
},
error: () => alert("Error occurred during changing password.")
});
return false;
});