Sha256: cd4d7de9ce32a7f24244b8d30f2307f55f4ceb239ba2dfd655e41f9166f0952e

Contents?: true

Size: 671 Bytes

Versions: 23

Compression:

Stored size: 671 Bytes

Contents

require 'rhoconnect/middleware/helpers'

module Rhoconnect
  module Middleware
    class CurrentUser
      
      def initialize(app)
        @app = app
      end

      def call(env)
        #puts "env is *** #{env.inspect}"
        env[Rhoconnect::CURRENT_USER] = extract_current_user(env)
        @app.call(env)
      end

      def extract_current_user(env)
        user = nil
        if User.is_exist?(env['rack.session'][:login])
          user = User.load(env['rack.session'][:login])
        end
        if user and (user.admin == 1 || env['rack.session'][:app_name] == APP_NAME)
          user
        else  
          nil
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 lib/rhoconnect/middleware/current_user.rb
rhoconnect-7.5.1 lib/rhoconnect/middleware/current_user.rb
rhoconnect-7.4.1 lib/rhoconnect/middleware/current_user.rb
rhoconnect-7.1.17 lib/rhoconnect/middleware/current_user.rb
rhoconnect-6.2.0 lib/rhoconnect/middleware/current_user.rb
rhoconnect-6.0.11 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.18 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.17 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.15 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.0.22 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.2 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.0.7 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.0.3 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.5.0 lib/rhoconnect/middleware/current_user.rb
rhoconnect-5.1.1 lib/rhoconnect/middleware/current_user.rb
rhoconnect-4.0.4 lib/rhoconnect/middleware/current_user.rb
rhoconnect-4.0.3 lib/rhoconnect/middleware/current_user.rb
rhoconnect-4.0.2 lib/rhoconnect/middleware/current_user.rb
rhoconnect-4.0.1 lib/rhoconnect/middleware/current_user.rb
rhoconnect-4.0.0 lib/rhoconnect/middleware/current_user.rb