From 61e0241d8930badc4a77cd973c3cbb64bd13c49e Mon Sep 17 00:00:00 2001
From: SleeplessOne1917 <abias1122@gmail.com>
Date: Mon, 7 Aug 2023 12:51:19 -0400
Subject: [PATCH] Fix password autocomplete (#2033)

---
 src/shared/components/common/password-input.tsx  | 4 +++-
 src/shared/components/home/setup.tsx             | 2 ++
 src/shared/components/home/signup.tsx            | 2 ++
 src/shared/components/person/password-change.tsx | 1 +
 src/shared/components/person/settings.tsx        | 6 ++++--
 5 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/shared/components/common/password-input.tsx b/src/shared/components/common/password-input.tsx
index 4298008..20cbadd 100644
--- a/src/shared/components/common/password-input.tsx
+++ b/src/shared/components/common/password-input.tsx
@@ -14,6 +14,7 @@ interface PasswordInputProps {
   showStrength?: boolean;
   label?: string | null;
   showForgotLink?: boolean;
+  isNew?: boolean;
 }
 
 interface PasswordInputState {
@@ -73,6 +74,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
         showStrength,
         label,
         showForgotLink,
+        isNew,
       },
       state: { show },
     } = this;
@@ -91,7 +93,7 @@ class PasswordInput extends Component<PasswordInputProps, PasswordInputState> {
                 type={show ? "text" : "password"}
                 className="form-control"
                 aria-describedby={id}
-                autoComplete="on"
+                autoComplete={isNew ? "new-password" : "current-password"}
                 onInput={onInput}
                 value={value}
                 required
diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx
index 7dd433a..0a3d09f 100644
--- a/src/shared/components/home/setup.tsx
+++ b/src/shared/components/home/setup.tsx
@@ -128,6 +128,7 @@ export class Setup extends Component<any, State> {
             value={this.state.form.password}
             onInput={linkEvent(this, this.handleRegisterPasswordChange)}
             label={I18NextService.i18n.t("password")}
+            isNew
           />
         </div>
         <div className="mb-3">
@@ -136,6 +137,7 @@ export class Setup extends Component<any, State> {
             value={this.state.form.password_verify}
             onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)}
             label={I18NextService.i18n.t("verify_password")}
+            isNew
           />
         </div>
         <div className="mb-3 row">
diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx
index fce37f9..58324be 100644
--- a/src/shared/components/home/signup.tsx
+++ b/src/shared/components/home/signup.tsx
@@ -189,6 +189,7 @@ export class Signup extends Component<any, State> {
             onInput={linkEvent(this, this.handleRegisterPasswordChange)}
             showStrength
             label={I18NextService.i18n.t("password")}
+            isNew
           />
         </div>
 
@@ -198,6 +199,7 @@ export class Signup extends Component<any, State> {
             value={this.state.form.password_verify}
             onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)}
             label={I18NextService.i18n.t("verify_password")}
+            isNew
           />
         </div>
 
diff --git a/src/shared/components/person/password-change.tsx b/src/shared/components/person/password-change.tsx
index bfbeb71..16f23d4 100644
--- a/src/shared/components/person/password-change.tsx
+++ b/src/shared/components/person/password-change.tsx
@@ -68,6 +68,7 @@ export class PasswordChange extends Component<any, State> {
             onInput={linkEvent(this, this.handlePasswordChange)}
             showStrength
             label={I18NextService.i18n.t("new_password")}
+            isNew
           />
         </div>
         <div className="mb-3">
diff --git a/src/shared/components/person/settings.tsx b/src/shared/components/person/settings.tsx
index 4b21d40..d045047 100644
--- a/src/shared/components/person/settings.tsx
+++ b/src/shared/components/person/settings.tsx
@@ -264,7 +264,7 @@ export class Settings extends Component<any, SettingsState> {
     );
   }
 
-  userSettings(isSelected) {
+  userSettings(isSelected: boolean) {
     return (
       <div
         className={classNames("tab-pane show", {
@@ -289,7 +289,7 @@ export class Settings extends Component<any, SettingsState> {
     );
   }
 
-  blockCards(isSelected) {
+  blockCards(isSelected: boolean) {
     return (
       <div
         className={classNames("tab-pane", {
@@ -326,6 +326,7 @@ export class Settings extends Component<any, SettingsState> {
               onInput={linkEvent(this, this.handleNewPasswordChange)}
               showStrength
               label={I18NextService.i18n.t("new_password")}
+              isNew
             />
           </div>
           <div className="mb-3">
@@ -334,6 +335,7 @@ export class Settings extends Component<any, SettingsState> {
               value={this.state.changePasswordForm.new_password_verify}
               onInput={linkEvent(this, this.handleNewPasswordVerifyChange)}
               label={I18NextService.i18n.t("verify_password")}
+              isNew
             />
           </div>
           <div className="mb-3">
-- 
2.44.1