2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-22 21:19:55 +00:00
|
|
|
class Admin::ImpersonationsController < Admin::ApplicationController
|
|
|
|
skip_before_action :authenticate_admin!
|
|
|
|
before_action :authenticate_impersonator!
|
|
|
|
|
|
|
|
def destroy
|
2018-11-24 12:39:16 +00:00
|
|
|
original_user = stop_impersonation
|
2018-07-02 10:43:06 +00:00
|
|
|
redirect_to admin_user_path(original_user), status: :found
|
2016-04-22 21:19:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authenticate_impersonator!
|
2017-04-09 02:20:57 +00:00
|
|
|
render_404 unless impersonator && impersonator.admin? && !impersonator.blocked?
|
2016-04-22 21:19:55 +00:00
|
|
|
end
|
|
|
|
end
|