Skip to content
Snippets Groups Projects

Implements saving new username and password in settings.js

Merged Maria Elizabeth Pauna Lane requested to merge brukerinstillinger into master
1 file
+ 15
1
Compare changes
  • Side-by-side
  • Inline
@@ -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"
}
Loading