* fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint line around directives issue * fix: eslint semi rule * fix: eslint newline per chain rule * fix: eslint space infix ops rule * fix: eslint space-in-parens issue * fix: eslint space before function paren issue * fix: eslint space before blocks issue * fix: eslint arrow body style issue * fix: eslint dot-location issue * fix: eslint quotes issue * fix: eslint quote props issue * fix: eslint operator assignment issue * fix: eslint new line after import issue * fix: indent issues * fix: operator assignment issue * fix: all autofixable eslint issues * fix: all react related fixable issues * fix: autofixable eslint issues * chore: remove all template literals * fix: remaining autofixable issues * chore: apply amnesty on all existing issues * fix: failing xss-lint issues * refactor: apply amnesty on remaining issues * refactor: apply amnesty on new issues * fix: remove file level suppressions * refactor: apply amnesty on new issues
32 lines
998 B
JavaScript
32 lines
998 B
JavaScript
import cookie from 'js-cookie';
|
|
|
|
const removeLoggedInCookies = () => {
|
|
// eslint-disable-next-line prefer-destructuring
|
|
const hostname = window.location.hostname;
|
|
const isLocalhost = hostname.indexOf('localhost') >= 0;
|
|
const isStage = hostname.indexOf('stage') >= 0;
|
|
|
|
let domain = '.edx.org';
|
|
if (isLocalhost) {
|
|
domain = 'localhost';
|
|
} else if (isStage) {
|
|
domain = '.stage.edx.org';
|
|
}
|
|
|
|
cookie.remove('edxloggedin', { domain });
|
|
|
|
if (isLocalhost) {
|
|
// localhost doesn't have prefixes
|
|
cookie.remove('csrftoken', { domain });
|
|
cookie.remove('edx-user-info', { domain });
|
|
} else {
|
|
// does not take sandboxes into account
|
|
const prefix = isStage ? 'stage' : 'prod';
|
|
// both stage and prod csrf tokens are set to .edx.org
|
|
cookie.remove(`${prefix}-edx-csrftoken`, { domain: '.edx.org' });
|
|
cookie.remove(`${prefix}-edx-user-info`, { domain });
|
|
}
|
|
};
|
|
|
|
export default removeLoggedInCookies;
|