57 lines
1.8 KiB
JavaScript
57 lines
1.8 KiB
JavaScript
function changePassword() {
|
|
oldPassword = document.getElementById("oldPassword").value
|
|
password = document.getElementById("password").value
|
|
confirmPassword = document.getElementById("confirmPassword").value
|
|
|
|
if ([oldPassword.length, password.length, confirmPassword.length].includes(0)) {
|
|
alert("Заполните все поля");
|
|
return;
|
|
}
|
|
|
|
if (password != confirmPassword) {
|
|
alert("Повторный пароль введен неверно");
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url:"/api/1.0/users/changePassword",
|
|
contentType: "application/json; charset=utf-8",
|
|
data: JSON.stringify({
|
|
"oldPassword": document.getElementById("oldPassword").value,
|
|
"password": document.getElementById("password").value,
|
|
"confirmPassword": document.getElementById("confirmPassword").value,
|
|
}),
|
|
method: "POST",
|
|
success: function() {
|
|
document.getElementById("closeModalPassword").click();
|
|
alert("Пароль был обновлен");
|
|
},
|
|
error: function(errorData) {
|
|
alert(errorData.responseJSON.error.message)
|
|
}
|
|
})
|
|
}
|
|
|
|
function inviteUser() {
|
|
email = document.getElementById("email").value;
|
|
re = /\S+@\S+\.\S+/;
|
|
|
|
|
|
if (!re.test(email)) {
|
|
alert("Некорректный почтовый ящик")
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
url:"/api/1.0/users/invite?email=" + email,
|
|
contentType: "application/json; charset=utf-8",
|
|
method: "POST",
|
|
success: function() {
|
|
document.getElementById("closeModalInvite").click();
|
|
alert("Пользователь был успешно приглашен");
|
|
},
|
|
error: function(errorData) {
|
|
alert(errorData.responseJSON.error.message)
|
|
}
|
|
})
|
|
} |