Disable password managers on some password forms (#503)

* Update index.tsx

add the data-lpignore attribute to the password component and remove redundant {} on autoComplete

* Update index.tsx

* add other password managers and disable ignore on main login
This commit is contained in:
Sam Machin
2025-04-11 08:19:46 -04:00
committed by GitHub
parent 3437d7f3d7
commit 94181873f3
2 changed files with 16 additions and 1 deletions
+15 -1
View File
@@ -8,6 +8,8 @@ type PasswdProps = JSX.IntrinsicElements["input"] & {
locked?: boolean; locked?: boolean;
/** This is optional in case an onChange override is necessary... */ /** This is optional in case an onChange override is necessary... */
setValue?: React.Dispatch<React.SetStateAction<string>>; setValue?: React.Dispatch<React.SetStateAction<string>>;
/** Whether to ignore password managers */
ignorePasswordManager?: boolean;
}; };
type PasswdRef = HTMLInputElement; type PasswdRef = HTMLInputElement;
@@ -22,16 +24,27 @@ export const Passwd = forwardRef<PasswdRef, PasswdProps>(
setValue, setValue,
placeholder, placeholder,
locked = false, locked = false,
ignorePasswordManager = true,
...restProps ...restProps
}: PasswdProps, }: PasswdProps,
ref, ref,
) => { ) => {
const [reveal, setReveal] = useState(false); const [reveal, setReveal] = useState(false);
// Create object with conditional password manager attributes
const passwordManagerAttributes = ignorePasswordManager
? {
"data-lpignore": "true",
"data-1p-ignore": "",
"data-form-type": "other",
"data-bwignore": "",
}
: {};
return ( return (
<div className="passwd"> <div className="passwd">
<input <input
autoComplete={"off"} autoComplete="off"
ref={ref} ref={ref}
type={reveal ? "text" : "password"} type={reveal ? "text" : "password"}
name={name} name={name}
@@ -43,6 +56,7 @@ export const Passwd = forwardRef<PasswdRef, PasswdProps>(
} }
}} }}
{...restProps} {...restProps}
{...passwordManagerAttributes}
/> />
{!locked && ( {!locked && (
<button <button
+1
View File
@@ -99,6 +99,7 @@ export const Login = () => {
value={password} value={password}
placeholder="Password" placeholder="Password"
setValue={setPassword} setValue={setPassword}
ignorePasswordManager={false}
/> />
{message && <Message message={message} />} {message && <Message message={message} />}
<Button type="submit">Log in</Button> <Button type="submit">Log in</Button>