Skip to content

Commit

Permalink
[NETTOYAGE] Extrais méthode pour améliorer lisibilité
Browse files Browse the repository at this point in the history
  • Loading branch information
egaillot committed May 14, 2024
1 parent 58fb4e2 commit 7c8c3f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/api/connexionFCPlus.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const stockeDansCookieSession = (infos, adaptateurChiffrement, requete) => adaptateurChiffrement
.genereJeton(infos)
.then((jwt) => { requete.session.jeton = jwt; });

const redirigeDepuisNavigateur = (destination, reponse) => reponse.send(`
<!DOCTYPE html>
<html>
Expand All @@ -13,8 +17,7 @@ const connexionFCPlus = (config, code, requete, reponse) => {

return fabriqueSessionFCPlus.nouvelleSession(code)
.then((session) => session.enJSON())
.then((infos) => adaptateurChiffrement.genereJeton(infos)
.then((jwt) => { requete.session.jeton = jwt; }))
.then((infos) => stockeDansCookieSession(infos, adaptateurChiffrement, requete))
.then(() => redirigeDepuisNavigateur('/', reponse))
.catch((e) => reponse.status(502).json({ erreur: `Échec authentification (${e.message})` }));
};
Expand Down

0 comments on commit 7c8c3f7

Please sign in to comment.