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

pull/3957/head
Arik Chakma 2 years 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 // Log the user in and reload the page
if (response?.token) { if (response?.token) {
Cookies.set(TOKEN_COOKIE_NAME, response.token); Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
});
window.location.reload(); window.location.reload();
return; return;

@ -59,7 +59,10 @@ export function GitHubButton(props: GitHubButtonProps) {
localStorage.removeItem(GITHUB_REDIRECT_AT); localStorage.removeItem(GITHUB_REDIRECT_AT);
localStorage.removeItem(GITHUB_LAST_PAGE); 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; window.location.href = redirectUrl;
}) })
.catch((err) => { .catch((err) => {

@ -57,7 +57,10 @@ export function GoogleButton(props: GoogleButtonProps) {
localStorage.removeItem(GOOGLE_REDIRECT_AT); localStorage.removeItem(GOOGLE_REDIRECT_AT);
localStorage.removeItem(GOOGLE_LAST_PAGE); 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; window.location.href = redirectUrl;
}) })
.catch((err) => { .catch((err) => {

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

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

Loading…
Cancel
Save