2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
class Admin::ImpersonationsController < Admin::ApplicationController
|
|
|
|
skip_before_action :authenticate_admin!
|
|
|
|
before_action :authenticate_impersonator!
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :authentication_and_authorization
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def destroy
|
2018-12-23 12:14:25 +05:30
|
|
|
original_user = stop_impersonation
|
2018-11-18 11:00:15 +05:30
|
|
|
redirect_to admin_user_path(original_user), status: :found
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authenticate_impersonator!
|
2017-08-17 22:00:37 +05:30
|
|
|
render_404 unless impersonator && impersonator.admin? && !impersonator.blocked?
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|