From af609afaca870246002bbc7b00ab211e49e636ee Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 23 May 2019 11:41:49 -0600 Subject: [PATCH] Fix log out using setCookie() --- src/js/account/setupListeners.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/js/account/setupListeners.js b/src/js/account/setupListeners.js index 0bd9146..19e9292 100644 --- a/src/js/account/setupListeners.js +++ b/src/js/account/setupListeners.js @@ -1,6 +1,7 @@ import { logIn, createAccount } from "./login"; import { saveEditModal, saveAndCloseEditModal } from "../dictionaryManagement"; import { saveEditModalAndSync, saveAndCloseEditModalAndSync } from "./dictionaryManagement"; +import { setCookie } from "../StackOverflow/cookie"; export function setupLoginModal(modal) { const closeElements = modal.querySelectorAll('.modal-background, .close-button'); @@ -16,9 +17,7 @@ export function setupLoginModal(modal) { export function setupLogoutButton(logoutButton) { logoutButton.addEventListener('click', () => { - const expire = new Date("November 1, 2015"), - path = window.location.pathname; - document.cookie = 'token=;expires=' + expire.toGMTString() + ';domain=' + document.domain + ';path=' + path; // + in front of `new Date` converts to a number + setCookie('token', '', -1); window.location.reload(); }); } @@ -28,7 +27,7 @@ export function setupEditFormButtonOverrides() { document.getElementById('editSave').addEventListener('click', saveEditModalAndSync); document.getElementById('editSaveAndClose').removeEventListener('click', saveAndCloseEditModal); document.getElementById('editSaveAndClose').addEventListener('click', saveAndCloseEditModalAndSync); - + // document.getElementById('importDictionaryFile').addEventListener('change', importDictionary); // document.getElementById('importWordsCSV').addEventListener('change', importWords); // document.getElementById('exportDictionaryButton').addEventListener('click', exportDictionary); @@ -36,4 +35,4 @@ export function setupEditFormButtonOverrides() { // document.getElementById('deleteDictionaryButton').addEventListener('click', confirmDeleteDictionary); // setupMaximizeButtons(); -} \ No newline at end of file +}