From 1bc043dd5e389c72f753e3092f25bb24a8cead9d Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 19 Oct 2023 00:00:15 +0200 Subject: [PATCH 01/18] update token --- web/js/config.js | 2 +- web/js/login.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/web/js/config.js b/web/js/config.js index 88833e4..8094a66 100644 --- a/web/js/config.js +++ b/web/js/config.js @@ -1 +1 @@ -const instance = axios.create({ baseURL: 'http://localhost:8083/api'}); \ No newline at end of file +const instance = axios.create({ baseURL: 'http://localhost:8083'}); \ No newline at end of file diff --git a/web/js/login.js b/web/js/login.js index e277061..4f312a5 100644 --- a/web/js/login.js +++ b/web/js/login.js @@ -6,7 +6,8 @@ document.getElementById("signin").addEventListener("submit", function(evt){ var pseudo = document.getElementById("floatingPseudo"); var password = document.getElementById("floatingPassword"); if((password.value.length > 0) || (pseudo.value.length > 0)){ - instance.get("token", { auth : {username: pseudo.value, password: password.value}, withCredentials: true}) + authData = {username: pseudo.value, password: password.value} + instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }}, { withCredentials: true}) .then(function(response) { location.href="html/users.html"; }) .catch(function(error){ From 326b21a65c9492d9e358845a9133b9f12b2633e5 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 20 Oct 2023 22:24:13 +0200 Subject: [PATCH 02/18] integ webcredentials --- web/js/config.js | 2 +- web/js/login.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/web/js/config.js b/web/js/config.js index 8094a66..8200117 100644 --- a/web/js/config.js +++ b/web/js/config.js @@ -1 +1 @@ -const instance = axios.create({ baseURL: 'http://localhost:8083'}); \ No newline at end of file +const instance = axios.create({ baseURL: 'http://localhost:8083', withCredentials: true}); \ No newline at end of file diff --git a/web/js/login.js b/web/js/login.js index 4f312a5..9fb6a49 100644 --- a/web/js/login.js +++ b/web/js/login.js @@ -7,8 +7,9 @@ document.getElementById("signin").addEventListener("submit", function(evt){ var password = document.getElementById("floatingPassword"); if((password.value.length > 0) || (pseudo.value.length > 0)){ authData = {username: pseudo.value, password: password.value} - instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }}, { withCredentials: true}) - .then(function(response) { location.href="html/users.html"; }) + instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }}) + .then(function(response) { + location.href="html/users.html"; }) .catch(function(error){ switch (error.response.status){ From 03ec97003e5aab1b4ebba72f35ab22b02449d6d6 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 20 Oct 2023 23:41:13 +0200 Subject: [PATCH 03/18] check roles users --- web/js/login.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/js/login.js b/web/js/login.js index 9fb6a49..8b5a898 100644 --- a/web/js/login.js +++ b/web/js/login.js @@ -9,7 +9,13 @@ document.getElementById("signin").addEventListener("submit", function(evt){ authData = {username: pseudo.value, password: password.value} instance.post("token", {username: pseudo.value, password: password.value}, {headers: {'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }}) .then(function(response) { - location.href="html/users.html"; }) + if(response.data["roles"] == "Admin"){ + location.href="html/users.html"; + } + else { + instance.delete("token") + } + }) .catch(function(error){ switch (error.response.status){ From 319ba75d437ce0a267d584fcb07277044119b796 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sat, 21 Oct 2023 10:18:21 +0200 Subject: [PATCH 04/18] add count --- web/js/users.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/js/users.js b/web/js/users.js index 7d530a9..c6aff94 100644 --- a/web/js/users.js +++ b/web/js/users.js @@ -30,8 +30,8 @@ for (var i=0; i Date: Sat, 21 Oct 2023 21:42:01 +0200 Subject: [PATCH 05/18] change param --- web/js/users.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/js/users.js b/web/js/users.js index c6aff94..1f697ca 100644 --- a/web/js/users.js +++ b/web/js/users.js @@ -2,7 +2,7 @@ checkToken(); signOut(); var param = {} -param["nbPages"] = 20; +param["limit"] = 20; var listSearch = [ "email", "uuid", "search"]; for(var i=0; i 1){ document.getElementById("page").classList.remove("hidden"); - var pageCurrent = getQuery("page"); + var pageCurrent = getQuery("skip"); var page = 1; if(pageCurrent.length > 0){ page = Number.parseInt(pageCurrent); @@ -68,11 +68,11 @@ instance.get("users/count", { withCredentials: true }).then(function(response){ }); -param["page"] = 0; -var pageCurrent = getQuery("page"); +param["skip"] = 0; +var pageCurrent = getQuery("skip"); if (pageCurrent.length > 0){ - param["page"] = Number.parseInt(pageCurrent); - param["page"] = param["page"] - 1; + param["skip"] = Number.parseInt(pageCurrent); + param["skip"] = param["skip"] - 1; } var listQuery = ["search", "uuid", "roles", "status", "email"]; From d4ef85c7aaf31e21791c8e036df40011353d9ad1 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Wed, 25 Oct 2023 23:43:46 +0200 Subject: [PATCH 06/18] update user --- web/html/user.html | 6 +++--- web/js/user.js | 12 ++++++------ web/js/users.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/html/user.html b/web/html/user.html index 4d3b390..2519a17 100644 --- a/web/html/user.html +++ b/web/html/user.html @@ -150,7 +150,7 @@ -
- Pseudo - + Pseudo +
diff --git a/web/js/user.js b/web/js/user.js index 842268e..3a63a0b 100644 --- a/web/js/user.js +++ b/web/js/user.js @@ -6,7 +6,7 @@ var id = getQuery("id"); if(id.length > 0){ instance.get("users/"+id, {withCredentials: true}) .then(function(response){ - var listValue = [ "id", "pseudo", "name", "firstName", "email", "birth"]; + var listValue = [ "id", "username", "name", "firstName", "email", "birth"]; var listTime = ["connected_at", "created_at", "updated_at", "deleted_at"]; for (var i=0; i 0){ switch(e.currentTarget.id){ case "disableUserButton": httpMethod = "delete"; - httpUrl = "users/disable/"+idInput; + httpUrl = "users/"+idInput; break; case "removeUserButton": httpMethod = "delete"; @@ -101,7 +101,7 @@ if(id.length > 0){ document.getElementById("updateUserButton").addEventListener("click", function(){ - var updateProfil = ["id", "pseudo", "email", "firstName", "birth"]; + var updateProfil = ["id", "username", "email", "firstName", "birth"]; var updateOk = true; for (var i=0; i 0){ dataPut = { "id": id, - "pseudo": document.getElementById("pseudoUpdateInput").value, + "username": document.getElementById("usernameUpdateInput").value, "email": document.getElementById("emailUpdateInput").value, "name": document.getElementById("nameUpdateInput").value, "firstName": document.getElementById("firstNameUpdateInput").value, @@ -139,8 +139,8 @@ if(id.length > 0){ } instance({ - method : "patch", - url:"users/"+id, + method : "put", + url:"users", withCredentials: true, data: dataPut }).then(function(response){ diff --git a/web/js/users.js b/web/js/users.js index 1f697ca..ebe955f 100644 --- a/web/js/users.js +++ b/web/js/users.js @@ -97,7 +97,7 @@ instance.get("users", {withCredentials: true, params :param}).then(function(resp var trAll = document.querySelectorAll("#users tbody tr") td = trAll[i].querySelectorAll("td"); td[0].textContent = listData[i].id; - td[1].textContent = listData[i].pseudo; + td[1].textContent = listData[i].username; td[2].textContent = listData[i].email; td[3].textContent = listData[i].roles; var classTd = ""; From 7bab6cd29a1163bbd27d5c80c6e9049bb362781e Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Thu, 26 Oct 2023 00:07:36 +0200 Subject: [PATCH 07/18] remove/disable user --- web/js/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/js/user.js b/web/js/user.js index 3a63a0b..6a86aa9 100644 --- a/web/js/user.js +++ b/web/js/user.js @@ -68,7 +68,7 @@ if(id.length > 0){ break; case "removeUserButton": httpMethod = "delete"; - httpUrl = "users/"+idInput; + httpUrl = "users/"+idInput+"?remove=true"; break; default: httpMethod = "patch"; From 28ab29d2b932d57eb410adcf7d5b56c726048ebf Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 27 Oct 2023 23:51:16 +0200 Subject: [PATCH 08/18] add user --- web/html/adduser.html | 6 +++--- web/js/addUser.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/html/adduser.html b/web/html/adduser.html index 3568f01..6526715 100644 --- a/web/html/adduser.html +++ b/web/html/adduser.html @@ -128,7 +128,7 @@
-
- Pseudo - + Pseudo +
diff --git a/web/js/addUser.js b/web/js/addUser.js index 766d6d7..c03578b 100644 --- a/web/js/addUser.js +++ b/web/js/addUser.js @@ -4,7 +4,7 @@ closeButton(); document.getElementById("addUser").addEventListener("click", function(){ - var updateProfil = ["pseudo", "email", "firstName", "birth", "password"]; + var updateProfil = ["username", "email", "firstName", "birth", "password"]; var updateOk = true; for (var i=0; i 0){ document.getElementById("displayUser").textContent=user; } @@ -68,7 +68,7 @@ document.getElementById("addUser").addEventListener("click", function(){ console.log(error); switch(error.response.status){ case 401: - listExist = [ "pseudo", "email" ]; + listExist = [ "username", "email" ]; for(var i=0; i Date: Fri, 27 Oct 2023 23:58:23 +0200 Subject: [PATCH 09/18] add syntaxe erreur --- web/html/adduser.html | 5 +++++ web/js/addUser.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/web/html/adduser.html b/web/html/adduser.html index 6526715..ff4f429 100644 --- a/web/html/adduser.html +++ b/web/html/adduser.html @@ -153,6 +153,11 @@
+ +