Sha256: b4b8c12abe0e977f5bfe7759bbb584fca82a632d8f922c1ae25150492c5e8bb3

Contents?: true

Size: 523 Bytes

Versions: 5

Compression:

Stored size: 523 Bytes

Contents

require 'request_store'

module ExpressAdmin
  module CurrentUser
    def self.included(base)
      base.class_eval do
        include InstanceMethods

        before_action do
          set_current_user
        end
      end
    end

    module InstanceMethods
      def set_current_user
        if defined? Devise
          # This allows `current_user` (if defined) to be accessible
          # outside a controller.
          RequestStore[:current_user] = self.try(:current_user)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
express_admin-2.0.0.b lib/express_admin/current_user.rb
express_admin-2.0.0.a lib/express_admin/current_user.rb
express_admin-1.8.1 lib/express_admin/current_user.rb
express_admin-1.8.0 lib/express_admin/current_user.rb
express_admin-1.7.32 lib/express_admin/current_user.rb