Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORRECTION] Sur erreur transmise par FC+, redirection vers page accueil #30

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/routes/routesAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand Down
7 changes: 4 additions & 3 deletions test/routes/routesAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<meta http-equiv="refresh" content="0; url=\'/\'">'))
.catch(leveErreur));

it('réinitialise le cookie de session', () => axios
.get(`http://localhost:${port}/auth/fcplus/connexion?error=boum&error_description=oups`)
Expand Down
Loading