FEATURE: log_out endpoint for admins

This commit is contained in:
Sam Saffron 2014-06-06 13:02:52 +10:00
parent 05ca1e6e46
commit d97ceb1d72
5 changed files with 27 additions and 0 deletions

View File

@ -174,6 +174,17 @@ Discourse.AdminUser = Discourse.User.extend({
});
},
log_out: function(){
Discourse.ajax("/admin/users/" + this.id + "/log_out", {
type: 'POST',
data: { username_or_email: this.get('username') }
}).then(
function(){
bootbox.alert(I18n.t("admin.user.logged_out"));
}
);
},
impersonate: function() {
Discourse.ajax("/admin/impersonate", {
type: 'POST',

View File

@ -14,6 +14,12 @@
{{i18n admin.user.impersonate}}
</button>
{{/if}}
{{#if currentUser.admin}}
<button class='btn' {{action log_out target="content"}}>
<i class='fa fa-power-off'></i>
{{i18n admin.user.log_out}}
</button>
{{/if}}
</div>
</div>

View File

@ -7,6 +7,7 @@ class Admin::UsersController < Admin::AdminController
before_filter :fetch_user, only: [:suspend,
:unsuspend,
:refresh_browsers,
:log_out,
:revoke_admin,
:grant_admin,
:revoke_moderation,
@ -56,6 +57,12 @@ class Admin::UsersController < Admin::AdminController
render nothing: true
end
def log_out
@user.auth_token = nil
@user.save!
render nothing: true
end
def refresh_browsers
refresh_browser @user
render nothing: true

View File

@ -1704,6 +1704,8 @@ en:
refresh_browsers: "Force browser refresh"
show_public_profile: "Show Public Profile"
impersonate: 'Impersonate'
log_out: "Log Out"
logged_out: "User was logged out on all devices"
revoke_admin: 'Revoke Admin'
grant_admin: 'Grant Admin'
revoke_moderation: 'Revoke Moderation'

View File

@ -62,6 +62,7 @@ Discourse::Application.routes.draw do
put "grant_moderation", constraints: AdminConstraint.new
put "approve"
post "refresh_browsers", constraints: AdminConstraint.new
post "log_out", constraints: AdminConstraint.new
put "activate"
put "deactivate"
put "block"