diff --git a/packages/ra-core/src/sideEffect/auth.ts b/packages/ra-core/src/sideEffect/auth.ts index a2088aab28b..452caac01bc 100644 --- a/packages/ra-core/src/sideEffect/auth.ts +++ b/packages/ra-core/src/sideEffect/auth.ts @@ -29,6 +29,12 @@ const nextPathnameSelector = state => { }; const currentPathnameSelector = state => state.router.location; +const getErrorMessage = (error, defaultMessage) => + typeof error === 'string' + ? error + : typeof error === 'undefined' || !error.message + ? defaultMessage + : error.message; export default (authProvider?: AuthProvider) => { if (!authProvider) { @@ -58,12 +64,10 @@ export default (authProvider?: AuthProvider) => { error: e, meta: { auth: true }, }); - const errorMessage = - typeof e === 'string' - ? e - : typeof e === 'undefined' || !e.message - ? 'ra.auth.sign_in_error' - : e.message; + const errorMessage = getErrorMessage( + e, + 'ra.auth.sign_in_error' + ); yield put(showNotification(errorMessage, 'warning')); } break; @@ -79,6 +83,11 @@ export default (authProvider?: AuthProvider) => { state: { nextPathname: meta.pathName }, }) ); + const errorMessage = getErrorMessage( + error, + 'ra.auth.auth_check_error' + ); + yield put(showNotification(errorMessage, 'warning')); } break; } diff --git a/packages/ra-language-english/index.js b/packages/ra-language-english/index.js index 97f12d32578..6b1512606db 100644 --- a/packages/ra-language-english/index.js +++ b/packages/ra-language-english/index.js @@ -89,6 +89,7 @@ module.exports = { prev: 'Prev', }, auth: { + auth_check_error: 'Please login to continue', user_menu: 'Profile', username: 'Username', password: 'Password', diff --git a/packages/ra-language-french/index.js b/packages/ra-language-french/index.js index f786c5c65f7..3839627227e 100644 --- a/packages/ra-language-french/index.js +++ b/packages/ra-language-french/index.js @@ -93,6 +93,7 @@ module.exports = { prev: 'Précédent', }, auth: { + auth_check_error: 'Merci de vous connecter pour continuer', user_menu: 'Profil', username: 'Identifiant', password: 'Mot de passe',