libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit a9db558fd0ef11aafa754e1f6d8bc57ea8f75092
parent 245b3ea998a9e095c4ca685a019364afb8b9f06a
Author: tanhengyeow <E0032242@u.nus.edu>
Date:   Wed,  1 Jul 2020 19:48:36 +0800

Update error handling logic for Login page

Diffstat:
Mfrontend/src/actions/auth.tsx | 2++
Mfrontend/src/components/login/Index.tsx | 11+++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/frontend/src/actions/auth.tsx b/frontend/src/actions/auth.tsx @@ -34,6 +34,8 @@ export const login = (nexusURL: string, username: string, password: string) => { .then((response) => { if (response.ok) { return response.json(); + } else if (response.status === 401) { + throw new Error('Invalid credentials'); } throw new Error('Cannot connect to server'); }) diff --git a/frontend/src/components/login/Index.tsx b/frontend/src/components/login/Index.tsx @@ -15,6 +15,10 @@ const Login = ({ loginConnect }: Props) => { const [username, setUsername] = useState('admin'); const [password, setPassword] = useState('x'); const [authenticationFailure, setAuthenticationFailure] = useState(false); + const [ + authenticationFailureMessage, + setAuthenticationFailureMessage, + ] = useState(''); const layout = { wrapperCol: { span: 32 }, @@ -25,7 +29,10 @@ const Login = ({ loginConnect }: Props) => { .then(() => { setAuthenticationFailure(false); }) - .catch((err) => setAuthenticationFailure(true)); + .catch((err) => { + setAuthenticationFailure(true); + setAuthenticationFailureMessage(err); + }); }; const enterPressed = (event) => { @@ -40,7 +47,7 @@ const Login = ({ loginConnect }: Props) => { {authenticationFailure ? ( <Alert message="Error" - description="Invalid credentials" + description={String(authenticationFailureMessage)} type="error" showIcon />