Files
edx-platform/lms/static/js/student_account/components/removeLoggedInCookies.js
Syed Ali Abbas Zaidi 5549db4d80 fix: migrate remaining eslint-config-edx (#31760)
* fix: migrate remaining eslint-config-edx

* refactor: updated eslint rules according to eslint-config-edx-es5

* refactor: add custom rules to suppress unnecessary eslint issues

* refactor: add custom rules to internal eslint configs

* fix: fix all indentation issues

* chore: update lock file
2023-03-02 16:16:50 +05:00

31 lines
945 B
JavaScript

import cookie from 'js-cookie';
const removeLoggedInCookies = () => {
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;