diff --git a/src/main/webapp/js/settings.js b/src/main/webapp/js/settings.js index c143d49f42604f3a929f67138c9283ac0e6e94b6..8ca107c7a2102f9bc163901673e44bb567668d4f 100644 --- a/src/main/webapp/js/settings.js +++ b/src/main/webapp/js/settings.js @@ -8,7 +8,10 @@ document.getElementById("cancelButton").addEventListener("click", function(){ */ function editUser (event) { event.preventDefault(); - let newInformation = {}; + let newInformation = { + "username": document.getElementById("newUsername").value, + "password": document.getElementById("newPassword").value, + }; fetch('../api/user/'+sessionStorage.getItem("userId"), { method: "PUT", @@ -25,4 +28,15 @@ function editUser (event) { } }) .catch(error => console.error(error)); + +} + +/** + * Adds user information to sessionStorage and redirects to app.html + * @param user contains user information as a JSON object + */ +function loadApplication(newInformation){ + sessionStorage.setItem("userId", newInformation.userId); + sessionStorage.setItem("username", newInformation.username); + window.location.href = "../app.html" }