88 rest changePassword + ajax
parent
4fc8bc3717
commit
052e4a1aef
@ -1,6 +1,7 @@
|
|||||||
package ru.ulstu.user.error;
|
package ru.ulstu.user.error;
|
||||||
|
|
||||||
public class UserPasswordsNotValidOrNotMatchException extends RuntimeException {
|
public class UserPasswordsNotValidOrNotMatchException extends RuntimeException {
|
||||||
public UserPasswordsNotValidOrNotMatchException() {
|
public UserPasswordsNotValidOrNotMatchException(String message) {
|
||||||
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorator="default" xmlns:th="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container" layout:fragment="content">
|
|
||||||
<section id="services">
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12 text-center">
|
|
||||||
<h2 class="section-heading text-uppercase"><span th:text="${error}"></span></h2>
|
|
||||||
<a href="/"><h3>Вернуться на главную</h3></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Loading…
Reference in New Issue