front
Gwenael PLANCHON 1 year ago
parent 3437616ec1
commit 3a343f738d

@ -17,23 +17,23 @@ export class Utilisateur extends DataObject{
}) })
return new this.constructor(await response.json()) return new this.constructor(await response.json())
} }
async connecter(){ async creerInvite(){
const response = await fetch(`${REST_API}/utilisateur/connexion`,{ const response = await fetch(`${REST_API}/invite`,{
method:"POST", method:"POST",
headers:{"Content-Type":"application/json"}, headers:{"Content-Type":"application/json"},
body:JSON.stringify(this) body:JSON.stringify(this)
}) })
const utilisateurConnecte=new this.constructor(await response.json()) return new this.constructor(await response.json())
localStorage.setItem("utilisateurConnecte",utilisateurConnecte)
return utilisateurConnecte;
} }
async creerInvite(){ async connecter(){
const response = await fetch(`${REST_API}/invite`,{ const response = await fetch(`${REST_API}/utilisateur/connexion`,{
method:"POST", method:"POST",
headers:{"Content-Type":"application/json"}, headers:{"Content-Type":"application/json"},
body:JSON.stringify(this) body:JSON.stringify(this)
}) })
return new this.constructor(await response.json()) const utilisateurConnecte=new this.constructor(await response.json())
localStorage.setItem("utilisateurConnecte",utilisateurConnecte)
return utilisateurConnecte;
} }
static async utilisateurConnecte(){ static async utilisateurConnecte(){
const utilisateur=localStorage.getItem("utilisateurConnecte") const utilisateur=localStorage.getItem("utilisateurConnecte")
@ -49,13 +49,16 @@ export class Utilisateur extends DataObject{
} }
} }
/* JSON de reference pour le get /* JSON de reference pour le get, et retour des autres fonctions
{"email":"amogus@amog.us", "pseudo":"amogus", "id":"2"} {"email":"amogus@amog.us", "pseudo":"amogus", "id":"2"}
*/ */
/* JSON de reference (creerCompte) /* JSON de reference (creerCompte)
{"email":"amogus@amog.us", "pseudo":"amogus", "motDePasse":"hunter2"} {"email":"amogus@amog.us", "pseudo":"amogus", "motDePasse":"hunter2"}
*/ */
/* JSON de reference (creerInvite)
{"pseudo":"amogus"}
*/
/* JSON de reference (connecter) /* JSON de reference (connecter)
in : {"email":"amogus@amog.us", "motDePasse":"hunter2"} in : {"email":"amogus@amog.us", "motDePasse":"hunter2"}
out : {"email":"amogus@amog.us", "pseudo":"amogus", "id":"2"} out : {"email":"amogus@amog.us", "pseudo":"amogus", "id":"2"}

Loading…
Cancel
Save