To demonstrate the issue: - Visit https://meta.discourse.org/#somethingHere while logged in - Click "log out" - You will be logged out, but the page will not be reloaded Setting `window.location.pathname = "/"` will not reload the page if there is a hash present. Using `window.location = "/"` gives us the desired behavior.
17 lines
523 B
JavaScript
17 lines
523 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 = Discourse.getURL("/");
|
|
} else {
|
|
window.location.href = redirect;
|
|
}
|
|
}
|