2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
class Admin::ImpersonateController < Admin::AdminController
|
|
|
|
|
|
|
|
def create
|
2013-06-06 03:14:32 -04:00
|
|
|
params.require(:username_or_email)
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-06-18 20:31:19 -04:00
|
|
|
user = User.find_by_username_or_email(params[:username_or_email])
|
2013-02-05 14:16:51 -05:00
|
|
|
raise Discourse::NotFound if user.blank?
|
|
|
|
|
|
|
|
guardian.ensure_can_impersonate!(user)
|
|
|
|
|
2014-11-06 04:58:47 -05:00
|
|
|
# log impersonate
|
|
|
|
StaffActionLogger.new(current_user).log_impersonate(user)
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
# Log on as the user
|
2018-11-12 09:34:12 -05:00
|
|
|
log_on_user(user, impersonate: true)
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
render body: nil
|
2013-02-07 10:45:24 -05:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
|
|
|
|
end
|