Skip to content
Snippets Groups Projects
Commit 4045eee5 authored by jaebradley's avatar jaebradley
Browse files

Remove cookies when retiring user

parent 48bff77b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import { Button, Modal, Icon, InputText, StatusAlert } from '@edx/paragon/static
import StringUtils from 'edx-ui-toolkit/js/utils/string-utils';
import { deactivate } from '../AccountsClient';
import removeLoggedInCookies from './removeLoggedInCookies';
class StudentAccountDeletionConfirmationModal extends React.Component {
constructor(props) {
......@@ -29,6 +30,7 @@ class StudentAccountDeletionConfirmationModal extends React.Component {
handleConfirmationModalClose() {
this.props.onClose();
removeLoggedInCookies();
window.location.href = 'https://www.edx.org';
}
......
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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment