gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: Show error message when authentication


From: gnunet
Subject: [libeufin] branch master updated: Show error message when authentication fails
Date: Thu, 11 Jun 2020 20:45:01 +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 d54d7f1  Show error message when authentication fails
d54d7f1 is described below

commit d54d7f131377f6e5ca6e00272ecdbd1b6a12a454
Author: tanhengyeow <E0032242@u.nus.edu>
AuthorDate: Fri Jun 12 02:44:47 2020 +0800

    Show error message when authentication fails
---
 frontend/src/actions/auth.tsx            |  4 ++--
 frontend/src/components/login/Index.tsx  | 25 ++++++++++++++++++++-----
 frontend/src/components/login/Login.less |  4 ++++
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/frontend/src/actions/auth.tsx b/frontend/src/actions/auth.tsx
index 80964fb..31f767f 100644
--- a/frontend/src/actions/auth.tsx
+++ b/frontend/src/actions/auth.tsx
@@ -35,7 +35,7 @@ export const login = (nexusURL: string, username: string, 
password: string) => {
           if (response.ok) {
             return response.json();
           }
-          throw new Error('Error connecting to server');
+          throw 'Cannot connect to server';
         })
         .then(async () => {
           await window.localStorage.setItem('authenticated', 'true');
@@ -46,7 +46,7 @@ export const login = (nexusURL: string, username: string, 
password: string) => {
           dispatch(authenticate());
         })
         .catch((err) => {
-          console.log(err);
+          throw new Error(err);
         });
     }
   };
diff --git a/frontend/src/components/login/Index.tsx 
b/frontend/src/components/login/Index.tsx
index 261eca3..e73e234 100644
--- a/frontend/src/components/login/Index.tsx
+++ b/frontend/src/components/login/Index.tsx
@@ -1,19 +1,20 @@
 import React, { useState } from 'react';
 import { connect } from 'react-redux';
-import { Form, Input, Button } from 'antd';
+import { Alert, Form, Input, Button } from 'antd';
 import { LoginOutlined } from '@ant-design/icons';
 import { login } from '../../actions/auth';
 import largeLogo from './libeufin-logo-large.png';
 import './Login.less';
 
 interface Props {
-  loginConnect: (nexusURL: string, username: string, password: string) => void;
+  loginConnect: (nexusURL: string, username: string, password: string) => any;
 }
 
 const Login = ({ loginConnect }: Props) => {
   const [nexusURL, setNexusURL] = useState('localhost:5000');
-  const [username, setUsername] = useState('user1');
-  const [password, setPassword] = useState('user1');
+  const [username, setUsername] = useState('admin');
+  const [password, setPassword] = useState('x');
+  const [authenticationFailure, setAuthenticationFailure] = useState(false);
 
   const layout = {
     wrapperCol: { span: 32 },
@@ -21,6 +22,14 @@ const Login = ({ loginConnect }: Props) => {
 
   return (
     <div className="login">
+      {authenticationFailure ? (
+        <Alert
+          message="Error"
+          description="Invalid credentials"
+          type="error"
+          showIcon
+        />
+      ) : null}
       <img className="img" src={largeLogo} alt="LibEuFin large logo" />
       <Form {...layout} size="large">
         <Form.Item>
@@ -46,7 +55,13 @@ const Login = ({ loginConnect }: Props) => {
           <Button
             type="primary"
             icon={<LoginOutlined />}
-            onClick={() => loginConnect(nexusURL, username, password)}
+            onClick={() =>
+              loginConnect(nexusURL, username, password)
+                .then(() => {
+                  setAuthenticationFailure(false);
+                })
+                .catch((err) => setAuthenticationFailure(true))
+            }
           >
             Login
           </Button>
diff --git a/frontend/src/components/login/Login.less 
b/frontend/src/components/login/Login.less
index bd8cb22..742c2d6 100644
--- a/frontend/src/components/login/Login.less
+++ b/frontend/src/components/login/Login.less
@@ -13,3 +13,7 @@
   display: flex;
   justify-content: flex-end;
 }
+
+.login .ant-alert-with-description {
+  margin-bottom: 20px;
+}

-- 
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]