From 3a9593ec076a8178b05ea9d9143c9b2599831df6 Mon Sep 17 00:00:00 2001 From: Thicham Date: Wed, 21 Jun 2023 14:55:08 +0200 Subject: [PATCH] fix: add error alert on login failure * fix: add error alert on login failure * fix: revert to send a JSON instead of formData --------- Co-authored-by: hicham --- src/services/aphp/servicePractitioner.ts | 10 +++++----- src/views/Login/Login.jsx | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/services/aphp/servicePractitioner.ts b/src/services/aphp/servicePractitioner.ts index 8dc273a19..61a3e053f 100644 --- a/src/services/aphp/servicePractitioner.ts +++ b/src/services/aphp/servicePractitioner.ts @@ -63,12 +63,12 @@ const servicePractitioner: IServicePractitioner = { authenticateWithCode: async (authCode: string) => { try { - const res = await apiBackend.post(`/auth/oidc/login`, { auth_code: authCode }) - if (res.status === 200) { - localStorage.setItem(ACCESS_TOKEN, res.data.jwt.access) - localStorage.setItem(REFRESH_TOKEN, res.data.jwt.refresh) + const response = await apiBackend.post(`/auth/oidc/login`, { auth_code: authCode }) + if (response.status === 200) { + localStorage.setItem(ACCESS_TOKEN, response.data.jwt.access) + localStorage.setItem(REFRESH_TOKEN, response.data.jwt.refresh) } - return res + return response } catch (error) { console.error('Error authenticating with an authorization code', error) return error diff --git a/src/views/Login/Login.jsx b/src/views/Login/Login.jsx index 7cacb2bd3..20095d2d6 100644 --- a/src/views/Login/Login.jsx +++ b/src/views/Login/Login.jsx @@ -314,6 +314,7 @@ const Login = () => { Connexion... + ) : authCode ? (