1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-31 04:59:50 +02:00

Cookie sharing across sub-domains

This commit is contained in:
Kamran Ahmed
2023-08-25 02:19:02 +01:00
parent 1a7a6db50c
commit b04b8c702f
7 changed files with 6 additions and 6 deletions

View File

@@ -29,6 +29,7 @@ const EmailLoginForm: FunctionComponent<{}> = () => {
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.reload();

View File

@@ -62,6 +62,7 @@ export function GitHubButton(props: GitHubButtonProps) {
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.href = redirectUrl;
})

View File

@@ -60,6 +60,7 @@ export function GoogleButton(props: GoogleButtonProps) {
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.href = redirectUrl;
})

View File

@@ -60,6 +60,7 @@ export function LinkedInButton(props: LinkedInButtonProps) {
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.href = redirectUrl;
})

View File

@@ -56,6 +56,7 @@ export default function ResetPasswordForm() {
Cookies.set(TOKEN_COOKIE_NAME, token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.href = '/';
};

View File

@@ -30,6 +30,7 @@ export function TriggerVerifyAccount() {
Cookies.set(TOKEN_COOKIE_NAME, response.token, {
path: '/',
expires: 30,
domain: import.meta.env.DEV ? 'localhost' : '.roadmap.sh',
});
window.location.href = '/';
})

View File

@@ -4,12 +4,6 @@ import { TOKEN_COOKIE_NAME } from '../../lib/jwt';
export function logout() {
Cookies.remove(TOKEN_COOKIE_NAME);
// @FIXME: fix the domain name in the cookie created by the API
Cookies.remove(TOKEN_COOKIE_NAME, {
path: '/',
domain: 'api.roadmap.sh',
});
// Reloading will automatically redirect the user if required
window.location.reload();
}