Browse Source

fix auth login

Signed-off-by: nameczz <zizhao.chen@zilliz.com>
nameczz 2 years ago
parent
commit
27ec77a181

+ 2 - 0
client/src/i18n/cn/common.ts

@@ -5,6 +5,8 @@ const commonTrans = {
     unAuth: 'Username or password is not correct',
     username: 'Username',
     password: 'Password',
+    optional: '(optional)',
+
     ssl: 'SSL',
   },
   status: {

+ 1 - 0
client/src/i18n/en/common.ts

@@ -5,6 +5,7 @@ const commonTrans = {
     unAuth: 'Username or password is not correct',
     username: 'Username',
     password: 'Password',
+    optional: '(optional)',
     ssl: 'SSL',
   },
   status: {

+ 31 - 49
client/src/pages/connect/AuthForm.tsx

@@ -77,7 +77,7 @@ export const AuthForm = (props: any) => {
   const checkedForm = useMemo(() => {
     return formatForm(form);
   }, [form]);
-  const { validation, checkIsValid, disabled } = useFormValidation(checkedForm);
+  const { validation, checkIsValid } = useFormValidation(checkedForm);
 
   const handleInputChange = (
     key: 'address' | 'username' | 'password' | 'ssl',
@@ -105,56 +105,38 @@ export const AuthForm = (props: any) => {
         defaultValue: form.address,
       },
     ];
-    return showAuthForm
-      ? [
-          ...noAuthConfigs,
-          {
-            label: attuTrans.username,
-            key: 'username',
-            onChange: (value: string) => handleInputChange('username', value),
-            variant: 'filled',
-            className: classes.input,
-            placeholder: attuTrans.username,
-            fullWidth: true,
-            validations: [
-              {
-                rule: 'require',
-                errorText: warningTrans('required', {
-                  name: attuTrans.username,
-                }),
-              },
-            ],
-            defaultValue: form.username,
-          },
-          {
-            label: attuTrans.password,
-            key: 'password',
-            onChange: (value: string) => handleInputChange('password', value),
-            variant: 'filled',
-            className: classes.input,
-            placeholder: attuTrans.password,
-            fullWidth: true,
-            type: 'password',
-            validations: [
-              {
-                rule: 'require',
-                errorText: warningTrans('required', {
-                  name: attuTrans.password,
-                }),
-              },
-            ],
-            defaultValue: form.username,
-          },
-        ]
-      : noAuthConfigs;
-  }, [form, attuTrans, warningTrans, classes.input, showAuthForm]);
+    return [
+      ...noAuthConfigs,
+      {
+        label: `${attuTrans.username} ${attuTrans.optional}`,
+        key: 'username',
+        onChange: (value: string) => handleInputChange('username', value),
+        variant: 'filled',
+        className: classes.input,
+        placeholder: attuTrans.username,
+        fullWidth: true,
+
+        defaultValue: form.username,
+      },
+      {
+        label: `${attuTrans.password} ${attuTrans.optional}`,
+        key: 'password',
+        onChange: (value: string) => handleInputChange('password', value),
+        variant: 'filled',
+        className: classes.input,
+        placeholder: attuTrans.password,
+        fullWidth: true,
+        type: 'password',
+
+        defaultValue: form.username,
+      },
+    ];
+  }, [form, attuTrans, warningTrans, classes.input]);
 
   const handleConnect = async () => {
     const address = formatAddress(form.address);
     try {
-      const data = showAuthForm
-        ? { ...form, address }
-        : { address, ssl: form.ssl };
+      const data = { ...form, address };
       await MilvusHttp.connect(data);
       setIsAuth(true);
       setAddress(address);
@@ -172,8 +154,8 @@ export const AuthForm = (props: any) => {
   };
 
   const btnDisabled = useMemo(() => {
-    return showAuthForm ? disabled : form.address.trim().length === 0;
-  }, [showAuthForm, disabled, form.address]);
+    return form.address.trim().length === 0;
+  }, [form.address]);
 
   return (
     <section className={classes.wrapper}>

+ 2 - 2
server/package.json

@@ -1,6 +1,6 @@
 {
   "name": "attu",
-  "version": "2.2.0",
+  "version": "2.2.1",
   "license": "MIT",
   "author": {
     "name": "zilliz",
@@ -140,4 +140,4 @@
       ]
     }
   }
-}
+}

+ 0 - 7
server/src/milvus/milvus.service.ts

@@ -81,13 +81,6 @@ export class MilvusService {
     } catch (error) {
       // if milvus is not working, delete connection.
       cache.del(milvusAddress);
-      /**
-       * When user change the user password, milvus will also return unauthenticated error.
-       * Need to care it in cloud service.
-       */
-      if (error.toString().includes('unauthenticated')) {
-        throw HttpErrors(HTTP_STATUS_CODE.UNAUTHORIZED, error);
-      }
       throw HttpErrors(HTTP_STATUS_CODE.BAD_REQUEST, error);
     }
   }