2013-02-05 13:16:51 -06:00
|
|
|
class Admin::ImpersonateController < Admin::AdminController
|
|
|
|
|
|
|
|
def create
|
2013-06-06 02:14:32 -05:00
|
|
|
params.require(:username_or_email)
|
2013-02-05 13:16:51 -06:00
|
|
|
|
2013-06-18 19:31:19 -05:00
|
|
|
user = User.find_by_username_or_email(params[:username_or_email])
|
2013-02-05 13:16:51 -06:00
|
|
|
raise Discourse::NotFound if user.blank?
|
|
|
|
|
|
|
|
guardian.ensure_can_impersonate!(user)
|
|
|
|
|
2014-11-06 03:58:47 -06:00
|
|
|
# log impersonate
|
|
|
|
StaffActionLogger.new(current_user).log_impersonate(user)
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
# Log on as the user
|
|
|
|
log_on_user(user)
|
|
|
|
|
|
|
|
render nothing: true
|
2013-02-07 09:45:24 -06:00
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
|
|
|
|
end
|