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!
|
|
|
|
|
|
|
|
def destroy
|
2019-02-15 15:39:39 +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
|