Sha256: 40c468328677b61c97fa6792b5a5fea6b0bb5bc7a2ee9671440e1180ce429edf

Contents?: true

Size: 733 Bytes

Versions: 127

Compression:

Stored size: 733 Bytes

Contents

module Effective
  module ImpersonationController
    module Impersonate

      def impersonate
        @user = current_user.class.find(params[:id])
        redirect_path = after_impersonate_path_for(@user)

        authorize! :impersonate, @user

        # Impersonate
        session[:impersonation_user_id] = current_user.id
        session[:impersonation_original_path] = request.referer.presence || '/admin/users'

        expire_data_after_sign_in!
        warden.session_serializer.store(@user, Devise::Mapping.find_scope!(@user))

        @user.touch

        redirect_to(redirect_path)
      end

      def after_impersonate_path_for(user)
        try(:dashboard_path) || try(:root_path) || '/'
      end

    end
  end
end

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
effective_resources-2.27.3 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.27.2 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.27.1 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.27.0 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.5 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.4 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.3 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.2 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.1 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.26.0 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.16 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.15 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.14 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.13 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.12 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.11 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.10 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.9 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.8 app/controllers/concerns/effective/impersonation_controller/impersonate.rb
effective_resources-2.25.7 app/controllers/concerns/effective/impersonation_controller/impersonate.rb