This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new f219a9376 feat: new password confirmation (#5170)
f219a9376 is described below

commit f219a9376fb8da0b89a89762d648484b061ceb1c
Author: Klesh Wong <[email protected]>
AuthorDate: Fri May 12 14:51:00 2023 +0800

    feat: new password confirmation (#5170)
---
 config-ui/src/pages/login/login.tsx | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/config-ui/src/pages/login/login.tsx 
b/config-ui/src/pages/login/login.tsx
index fe3dba5c1..d130797c8 100644
--- a/config-ui/src/pages/login/login.tsx
+++ b/config-ui/src/pages/login/login.tsx
@@ -31,8 +31,14 @@ export const LoginPage = () => {
   const [username, setUsername] = useState(localStorage.getItem('username') || 
'');
   const [password, setPassword] = useState('');
   const [newPassword, setNewPassword] = useState('');
+  const [confirmNewPassword, setConfirmNewPassword] = useState('');
   const [challenge, setChallenge] = useState('');
   const [session, setSession] = useState('');
+  const loginDisabled =
+    !username ||
+    !password ||
+    (challenge === 'NEW_PASSWORD_REQUIRED' &&
+      (!newPassword || !confirmNewPassword || newPassword !== 
confirmNewPassword));
 
   const history = useHistory();
 
@@ -94,16 +100,26 @@ export const LoginPage = () => {
           />
         </FormGroup>
         {challenge === 'NEW_PASSWORD_REQUIRED' && (
-          <FormGroup label="Set New Password">
-            <InputGroup
-              type="password"
-              placeholder="Please set a new Password for your account"
-              value={newPassword}
-              onChange={(e) => setNewPassword((e.target as 
HTMLInputElement).value)}
-            />
-          </FormGroup>
+          <>
+            <FormGroup label="Set New Password">
+              <InputGroup
+                type="password"
+                placeholder="Please set a new Password for your account"
+                value={newPassword}
+                onChange={(e) => setNewPassword((e.target as 
HTMLInputElement).value)}
+              />
+            </FormGroup>
+            <FormGroup label="Confirm New Password">
+              <InputGroup
+                type="password"
+                placeholder="Please repeat your New Password"
+                value={confirmNewPassword}
+                onChange={(e) => setConfirmNewPassword((e.target as 
HTMLInputElement).value)}
+              />
+            </FormGroup>
+          </>
         )}
-        <Button intent={Intent.PRIMARY} onClick={handleSubmit}>
+        <Button intent={Intent.PRIMARY} onClick={handleSubmit} 
disabled={loginDisabled}>
           Login
         </Button>
       </S.Inner>

Reply via email to