diff --git a/src/main/resources/public/js/users.js b/src/main/resources/public/js/users.js index acf04c7..3f4af95 100644 --- a/src/main/resources/public/js/users.js +++ b/src/main/resources/public/js/users.js @@ -17,17 +17,42 @@ function changePassword() { url:"/api/1.0/users/changePassword", contentType: "application/json; charset=utf-8", data: JSON.stringify({ - "oldPassword": oldPassword, - "password": password, - "confirmPassword": confirmPassword, + "oldPassword": document.getElementById("oldPassword").value, + "password": document.getElementById("password").value, + "confirmPassword": document.getElementById("confirmPassword").value, }), method: "POST", success: function() { document.getElementById("closeModalPassword").click(); - alert("Пароль был обновлен"); + showFeedbackMessage("Пароль был обновлен", MessageTypesEnum.SUCCESS) + }, error: function(errorData) { - alert(errorData.responseJSON.error.message) + showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING) + } + }) +} + +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(); + showFeedbackMessage("Пользователь был успешно приглашен", MessageTypesEnum.SUCCESS) + }, + error: function(errorData) { + showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING) } }) } \ No newline at end of file