discourse/app/controllers/admin/impersonate_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
487 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-02-06 03:16:51 +08:00
class Admin::ImpersonateController < Admin::AdminController
def create
params.require(:username_or_email)
2013-02-06 03:16:51 +08:00
user = User.find_by_username_or_email(params[:username_or_email])
2013-02-06 03:16:51 +08:00
raise Discourse::NotFound if user.blank?
guardian.ensure_can_impersonate!(user)
2014-11-06 17:58:47 +08:00
# log impersonate
StaffActionLogger.new(current_user).log_impersonate(user)
2013-02-06 03:16:51 +08:00
# Log on as the user
log_on_user(user, impersonate: true)
2013-02-06 03:16:51 +08:00
render body: nil
2013-02-07 23:45:24 +08:00
end
2013-02-06 03:16:51 +08:00
end