Class: Tbone::Devise::Middleware
- Inherits:
-
Object
- Object
- Tbone::Devise::Middleware
- Defined in:
- lib/tbone/devise/engine.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
- #render_user(user) ⇒ Object
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
13 14 15 |
# File 'lib/tbone/devise/engine.rb', line 13 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tbone/devise/engine.rb', line 16 def call(env) warden = env['warden'] return @app.call(env) if env['REQUEST_PATH'] =~ /^\/assets/ user = warden.authenticate m = self Tbone.configure do |c| c.add_params currentUser: m.render_user(user || User.new) c.add_params guestUser: m.render_user(User.new) end @app.call(env) end |
#render_user(user) ⇒ Object
27 28 29 |
# File 'lib/tbone/devise/engine.rb', line 27 def render_user(user) Rabl.render(user, 'users/show', view_path: 'app/views', format: :hash) end |