From e9d0c4f4923258fa074d7f4f5b0e827c8c5d45e8 Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao <_accounts@nareshkumarrao.com> Date: Tue, 27 Jul 2021 17:49:27 +0200 Subject: [PATCH] better error messaging --- src/screens/LoginScreen.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/screens/LoginScreen.js b/src/screens/LoginScreen.js index 7d3a751..893cc08 100644 --- a/src/screens/LoginScreen.js +++ b/src/screens/LoginScreen.js @@ -70,14 +70,27 @@ function Login() { } }) .catch(err => { - dispatch(authLogout()); - toast({ - title: 'An error occurred', - description: 'Sorry, an error occurred on our side.', - status: 'error', - duration: 9000, - isClosable: true, - }); + if(err.response){ + if(err.response.status === 401){ + dispatch(authLogout()); + toast({ + title: 'Login Failed', + description: 'The wrong credentials were used.', + status: 'error', + duration: 9000, + isClosable: true, + }); + } + }else{ + toast({ + title: 'An error occurred', + description: 'Sorry, an error occurred on our side.', + status: 'error', + duration: 9000, + isClosable: true, + }); + } + }); e.preventDefault();