FEATURE: log_out endpoint for admins
This commit is contained in:
parent
05ca1e6e46
commit
d97ceb1d72
|
@ -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',
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue