Cookie sharing across sub-domains

pull/4428/head
Kamran Ahmed 1 year ago
parent 1a7a6db50c
commit b04b8c702f
  1. 1
      src/components/AuthenticationFlow/EmailLoginForm.tsx
  2. 1
      src/components/AuthenticationFlow/GitHubButton.tsx
  3. 1
      src/components/AuthenticationFlow/GoogleButton.tsx
  4. 1
      src/components/AuthenticationFlow/LinkedInButton.tsx
  5. 1
      src/components/AuthenticationFlow/ResetPasswordForm.tsx
  6. 1
      src/components/AuthenticationFlow/TriggerVerifyAccount.tsx
  7. 6
      src/components/Navigation/navigation.ts

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

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

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

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

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

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

@ -4,12 +4,6 @@ import { TOKEN_COOKIE_NAME } from '../../lib/jwt';
export function logout() { export function logout() {
Cookies.remove(TOKEN_COOKIE_NAME); 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 // Reloading will automatically redirect the user if required
window.location.reload(); window.location.reload();
} }

Loading…
Cancel
Save