mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-11 04:41:20 +08:00
The following upcoming changes have now progressed past stable, with the following effect: * enable_form_templates - Default to true and shows as a normal site setting. * impersonate_without_logout - Site setting removed, this is the new behaviour for impersonation. * enable_auto_grid_images - Default to true and shows as a normal site setting. The upcoming change metadata for these items has now been removed.
32 lines
818 B
Ruby
32 lines
818 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::ImpersonateController < Admin::AdminController
|
|
skip_before_action :ensure_admin, only: :destroy
|
|
|
|
def create
|
|
params.require(:username_or_email)
|
|
|
|
user = User.find_by_username_or_email(params[:username_or_email])
|
|
raise Discourse::NotFound if user.blank?
|
|
|
|
guardian.ensure_can_impersonate!(user)
|
|
|
|
StaffActionLogger.new(current_user).log_impersonate(user)
|
|
|
|
raise Discourse::InvalidAccess if current_user.is_impersonating
|
|
|
|
start_impersonating_user(user)
|
|
|
|
render body: nil
|
|
end
|
|
|
|
def destroy
|
|
raise Discourse::InvalidAccess unless current_user.is_impersonating
|
|
|
|
impersonated_user = current_user
|
|
stop_impersonating_user
|
|
StaffActionLogger.new(current_user).log_stop_impersonation(impersonated_user)
|
|
|
|
render body: nil
|
|
end
|
|
end
|