Class: Rhoconnect::Middleware::CurrentUser
- Inherits:
-
Object
- Object
- Rhoconnect::Middleware::CurrentUser
- Defined in:
- lib/rhoconnect/middleware/current_user.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #extract_current_user(env) ⇒ Object
-
#initialize(app) ⇒ CurrentUser
constructor
A new instance of CurrentUser.
Constructor Details
#initialize(app) ⇒ CurrentUser
Returns a new instance of CurrentUser.
7 8 9 |
# File 'lib/rhoconnect/middleware/current_user.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 |
# File 'lib/rhoconnect/middleware/current_user.rb', line 11 def call(env) #puts "env is *** #{env.inspect}" env[Rhoconnect::CURRENT_USER] = extract_current_user(env) @app.call(env) end |
#extract_current_user(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rhoconnect/middleware/current_user.rb', line 17 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 |