gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Update error handling logic for Login


From: gnunet
Subject: [libeufin] branch master updated: Update error handling logic for Login page
Date: Wed, 01 Jul 2020 13:49:08 +0200

This is an automated email from the git hooks/post-receive script.

heng-yeow pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new a9db558  Update error handling logic for Login page
a9db558 is described below

commit a9db558fd0ef11aafa754e1f6d8bc57ea8f75092
Author: tanhengyeow <E0032242@u.nus.edu>
AuthorDate: Wed Jul 1 19:48:36 2020 +0800

    Update error handling logic for Login page
---
 frontend/src/actions/auth.tsx           |  2 ++
 frontend/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
index 5dba687..47f67f7 100644
--- 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
index 15f2b50..979a047 100644
--- 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
         />

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]