From 514ec73191e20ae1d51e53438ab3042a06a75210 Mon Sep 17 00:00:00 2001 From: Emmanuel Gaillot Date: Tue, 25 Jun 2024 15:30:08 +0200 Subject: [PATCH] Sur erreur transmise par FC+, redirection vers page accueil Co-authored-by: Fabien Lamarque --- src/routes/routesAuth.js | 5 ++--- test/routes/routesAuth.spec.js | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/routes/routesAuth.js b/src/routes/routesAuth.js index d9807f6..bcb3efd 100644 --- a/src/routes/routesAuth.js +++ b/src/routes/routesAuth.js @@ -36,11 +36,10 @@ const routesAuth = (config) => { }); routes.get('/fcplus/connexion', (requete, reponse) => { - const { code, state } = requete.query; - const { error, error_description: descriptionErreur } = requete.query; + const { code, error, state } = requete.query; if (typeof error !== 'undefined') { requete.session = null; - reponse.render('erreur', { descriptionErreur }); + reponse.render('redirectionNavigateur', { destination: '/' }); } else if (typeof state === 'undefined' || state === '') { reponse.status(400).json({ erreur: "Paramètre 'state' absent de la requête" }); } else if (typeof code === 'undefined' || code === '') { diff --git a/test/routes/routesAuth.spec.js b/test/routes/routesAuth.spec.js index 762175f..a96b488 100644 --- a/test/routes/routesAuth.spec.js +++ b/test/routes/routesAuth.spec.js @@ -38,9 +38,10 @@ describe('Le serveur des routes `/auth`', () => { }); describe('sur GET /auth/fcplus/connexion', () => { - it("redirige vers une page d'erreur si le paramètre `error` est présent", () => axios - .get(`http://localhost:${port}/auth/fcplus/connexion?error=boum&error_description=oups`) - .then((reponse) => expect(reponse.data).toContain('oups'))); + it("redirige vers la page d'accueil si le paramètre `error` est présent", () => axios + .get(`http://localhost:${port}/auth/fcplus/connexion?error=boum`) + .then((reponse) => expect(reponse.data).toContain('')) + .catch(leveErreur)); it('réinitialise le cookie de session', () => axios .get(`http://localhost:${port}/auth/fcplus/connexion?error=boum&error_description=oups`)