From a9c3de6eb60ef9ef87051bebd7cb5c5fe11fdbe1 Mon Sep 17 00:00:00 2001 From: "gwenael.planchon" Date: Wed, 27 Mar 2024 15:56:57 +0100 Subject: [PATCH] ne plus hasher le mdp nous meme --- science-quest/src/components/Inscription.vue | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/science-quest/src/components/Inscription.vue b/science-quest/src/components/Inscription.vue index 58de3dd..6f04c0b 100644 --- a/science-quest/src/components/Inscription.vue +++ b/science-quest/src/components/Inscription.vue @@ -6,21 +6,9 @@ export default { creerCompte(event){ event.stopPropagation() let donnees=Object.fromEntries(new FormData(formajouter)) - this.hasherMDP(donnees.motDePasse).then(hashMDP=>{ - donnees.motDePasse=hashMDP - const donneesJson=JSON.stringify(donnees) - console.log(donnees) - fetch(REST_API+"/utilisateur", {method:"POST", body:donneesJson, headers:{"Content-Type":"application/json"}}).then(response=>console.log(response)) - }) - }, - async hasherMDP(mdp){ - const msgUint8 = new TextEncoder().encode(mdp); //transformer le string en array de bytes - const hashBuffer = await crypto.subtle.digest(ALGO_HASH_MDP, msgUint8); //hasher le mot de passe - const hashArray = Array.from(new Uint8Array(hashBuffer)); - const hashHex = hashArray - .map((b) => b.toString(16).padStart(2, "0")) //convertir chaque byte en hex - .join(""); - return hashHex; + const donneesJson=JSON.stringify(donnees) + console.log(donnees) + fetch(REST_API+"/utilisateur", {method:"POST", body:donneesJson, headers:{"Content-Type":"application/json"}}).then(response=>console.log(response)) } }