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

31 lines
649 B
JavaScript

import logout from 'discourse/lib/logout';
let _showingLogout = false;
// 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');
if (!messageBus) { return; }
messageBus.subscribe("/logout", function () {
if (!_showingLogout) {
_showingLogout = true;
bootbox.dialog(I18n.t("logout"), {
label: I18n.t("refresh"),
callback: logout
}, {
onEscape: logout,
backdrop: 'static'
});
}
});
}
};