FEATURE: log out user everywhere and refresh/redirect

This commit is contained in:
Arpit Jalan 2014-11-18 21:17:38 +05:30
parent b4844d4477
commit eb9eada894
3 changed files with 26 additions and 0 deletions

View 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'})
});
}
};

View File

@ -68,6 +68,7 @@ class Admin::UsersController < Admin::AdminController
def log_out
@user.auth_token = nil
@user.save!
MessageBus.publish "/logout", @user.id, user_ids: [@user.id]
render nothing: true
end

View File

@ -535,6 +535,8 @@ en:
fixed: "Load Page"
close: "Close"
assets_changed_confirm: "This site was just updated. Refresh now for the latest version?"
logout: "You were logged out."
refresh: "Refresh"
read_only_mode:
enabled: "An administrator enabled read-only mode. You can continue to browse the site but interactions may not work."
login_disabled: "Login is disabled while the site is in read only mode."