Skip to content

Commit

Permalink
implement a hack to try and make safari/chrome suggest saving the pas…
Browse files Browse the repository at this point in the history
…sword after submitting the login form
  • Loading branch information
JustAman62 committed Aug 30, 2024
1 parent 2a4f89d commit c24cf9d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ui/src/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,23 @@ export default function UserContextProvider({ children }: React.PropsWithChildre
return json.IdToken as string;
};

const onClose = () => {
setIsLoginOpen(false);
// history.pushState({}, "", `${window.location.toString()}#`)
const request = new XMLHttpRequest();
request.open('POST', '/index.html', true); // use a real url you have instead of '/success.html'
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send();
}

return (
<UserContext.Provider value={{ user: user, isLoggedIn: isLoggedIn, showLogin: showLogin, logout: logout, refreshToken }}>
{children}

{isLoggedIn ? (
<UserModal show={isLoginOpen} onClose={() => setIsLoginOpen(false)} />
<UserModal show={isLoginOpen} onClose={onClose} />
) : (
<LoginModal show={isLoginOpen} onClose={() => setIsLoginOpen(false)} setUser={setUser} />
<LoginModal show={isLoginOpen} onClose={onClose} setUser={setUser} />
)}
</UserContext.Provider>
);
Expand Down Expand Up @@ -230,7 +239,7 @@ function LoginModal({
</Button>
</ButtonGroup>

<form onSubmit={(e) => (type === "login" ? login(e) : register(e))}>
<form action="#" onSubmit={(e) => (type === "login" ? login(e) : register(e))} autoComplete="on">
<FloatingLabel
id="username"
name="username"
Expand Down

0 comments on commit c24cf9d

Please sign in to comment.