discourse/app/assets/javascripts/discourse/lib/logout.js.es6
Sam 0134e41286 FEATURE: detect when client thinks user is logged on but is not
This cleans up an error condition where UI thinks a user is logged on
but the user is not. If this happens user will be prompted to refresh.
2018-03-06 16:49:31 +11:00

17 lines
532 B
JavaScript

export default function logout(siteSettings, keyValueStore) {
if (!siteSettings || !keyValueStore) {
const container = Discourse.__container__;
siteSettings = siteSettings || container.lookup('site-settings:main');
keyValueStore = keyValueStore || container.lookup('key-value-store:main');
}
keyValueStore.abandonLocal();
const redirect = siteSettings.logout_redirect;
if (Ember.isEmpty(redirect)) {
window.location.pathname = Discourse.getURL('/');
} else {
window.location.href = redirect;
}
}