mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 05:18:00 +08:00
FEATURE: log out user everywhere and refresh/redirect
This commit is contained in:
23
app/assets/javascripts/discourse/initializers/logout.js.es6
Normal file
23
app/assets/javascripts/discourse/initializers/logout.js.es6
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
Subscribe to "logout" change events via the Message Bus
|
||||
**/
|
||||
export default {
|
||||
name: "logout",
|
||||
after: "message-bus",
|
||||
|
||||
initialize: function () {
|
||||
if (!Discourse.MessageBus) { return; }
|
||||
|
||||
Discourse.MessageBus.subscribe("/logout", function (user_id) {
|
||||
var refresher = function() {
|
||||
var redirect = Discourse.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'})
|
||||
});
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user