diff --git a/frontend/src/sagas/auth.sagas.js b/frontend/src/sagas/auth.sagas.js index da7d2e2..a2df936 100644 --- a/frontend/src/sagas/auth.sagas.js +++ b/frontend/src/sagas/auth.sagas.js @@ -2,6 +2,8 @@ import { call, put } from 'redux-saga/effects'; import { loginFailure, loginSuccess, logoutFailure, logoutSuccess } from '../actions/auth.actions'; import { addMessage } from '../actions/message.actions'; import { APIClient } from '../services/api-client.service.js'; +import { UnauthorizedError } from '../errors/unauthorized.error.js'; + export function* loginSaga(action) { const client = new APIClient(); @@ -9,10 +11,14 @@ export function* loginSaga(action) { try { result = yield call(client.login, action.username, action.password); } catch(err) { - console.error(err); + if (err instanceof UnauthorizedError) { + yield put(addMessage('warning', "Identifiants invalides.")); + return; + } + yield put(loginFailure(action.username, err)); yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard.")); - return + return } if ('error' in result) {