This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/lib/logout.js.es6
David Taylor 39f7e98b60
FIX: Ensure page is reloaded correctly when a hash is present (#8096)
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.
2019-09-16 13:27:12 +01:00

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;
}
}