mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-17 14:41:52 +02:00
fix: user gets logged out on browser quit (#3947)
This commit is contained in:
@@ -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) => {
|
||||||
|
Reference in New Issue
Block a user