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/initializers/logout.js.es6
Robin Ward 69851bc6cf Deprecates global use of Discourse.MessageBus
We can use DI for this, which makes it easier for plugins to subscribe
to the message bus.
2015-03-12 12:27:30 -04:00

25 lines
777 B
JavaScript

// Subscribe to "logout" change events via the Message Bus
export default {
name: "logout",
after: "message-bus",
initialize: function (container) {
const messageBus = container.lookup('message-bus:main'),
siteSettings = container.lookup('site-settings:main');
if (!messageBus) { return; }
messageBus.subscribe("/logout", function () {
var refresher = function() {
var redirect = siteSettings.logout_redirect;
if(redirect.length === 0){
window.location.pathname = Discourse.getURL('/');
} else {
window.location.href = redirect;
}
};
bootbox.dialog(I18n.t("logout"), {label: I18n.t("refresh"), callback: refresher}, {onEscape: refresher, backdrop: 'static'});
});
}
};