fix: user gets logged out on browser quit (#3947)

pull/3957/head
Arik Chakma 1 year ago committed by GitHub
parent 205fe6cc23
commit 82a44ddfef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/components/AuthenticationFlow/EmailLoginForm.tsx
  2. 5
      src/components/AuthenticationFlow/GitHubButton.tsx
  3. 5
      src/components/AuthenticationFlow/GoogleButton.tsx
  4. 7
      src/components/AuthenticationFlow/ResetPasswordForm.tsx
  5. 5
      src/components/AuthenticationFlow/TriggerVerifyAccount.tsx

@ -26,7 +26,10 @@ const EmailLoginForm: FunctionComponent<{}> = () => {
// Log the user in and reload the page
if (response?.token) {
Cookies.set(TOKEN_COOKIE_NAME, response.token);
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
});
window.location.reload();
return;

@ -59,7 +59,10 @@ export function GitHubButton(props: GitHubButtonProps) {
localStorage.removeItem(GITHUB_REDIRECT_AT);
localStorage.removeItem(GITHUB_LAST_PAGE);
Cookies.set(TOKEN_COOKIE_NAME, response.token);
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
});
window.location.href = redirectUrl;
})
.catch((err) => {

@ -57,7 +57,10 @@ export function GoogleButton(props: GoogleButtonProps) {
localStorage.removeItem(GOOGLE_REDIRECT_AT);
localStorage.removeItem(GOOGLE_LAST_PAGE);
Cookies.set(TOKEN_COOKIE_NAME, response.token);
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
});
window.location.href = redirectUrl;
})
.catch((err) => {

@ -1,7 +1,7 @@
import { useEffect, useState } from 'preact/hooks';
import { httpPost } from '../../lib/http';
import Cookies from 'js-cookie';
import {TOKEN_COOKIE_NAME} from "../../lib/jwt";
import { TOKEN_COOKIE_NAME } from '../../lib/jwt';
export default function ResetPasswordForm() {
const [code, setCode] = useState('');
@ -53,7 +53,10 @@ export default function ResetPasswordForm() {
}
const token = response.token;
Cookies.set(TOKEN_COOKIE_NAME, token);
Cookies.set(TOKEN_COOKIE_NAME, token, {
path: '/',
expires: 30,
});
window.location.href = '/';
};

@ -27,7 +27,10 @@ export function TriggerVerifyAccount() {
return;
}
Cookies.set(TOKEN_COOKIE_NAME, response.token);
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
});
window.location.href = '/';
})
.catch((err) => {

Loading…
Cancel
Save