|
|
@ -6,21 +6,9 @@ export default {
|
|
|
|
creerCompte(event){
|
|
|
|
creerCompte(event){
|
|
|
|
event.stopPropagation()
|
|
|
|
event.stopPropagation()
|
|
|
|
let donnees=Object.fromEntries(new FormData(formajouter))
|
|
|
|
let donnees=Object.fromEntries(new FormData(formajouter))
|
|
|
|
this.hasherMDP(donnees.motDePasse).then(hashMDP=>{
|
|
|
|
const donneesJson=JSON.stringify(donnees)
|
|
|
|
donnees.motDePasse=hashMDP
|
|
|
|
console.log(donnees)
|
|
|
|
const donneesJson=JSON.stringify(donnees)
|
|
|
|
fetch(REST_API+"/utilisateur", {method:"POST", body:donneesJson, headers:{"Content-Type":"application/json"}}).then(response=>console.log(response))
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|