Skip to content

Commit

Permalink
fix: add error alert on login failure
Browse files Browse the repository at this point in the history
* fix: add error alert on login failure

* fix: revert to send a JSON instead of formData

---------

Co-authored-by: hicham <hicham.taroq-ext@aphp.fr>
  • Loading branch information
thicham43 and hicham authored Jun 21, 2023
1 parent 2eaa0d6 commit 3a9593e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/services/aphp/servicePractitioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/views/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ const Login = () => {
Connexion...
</Typography>
<CircularProgress />
<ErrorSnackBarAlert open={error !== false} setError={setError} errorMessage={errorMessage} />
</Grid>
) : authCode ? (
<Welcome />
Expand Down

0 comments on commit 3a9593e

Please sign in to comment.