Class: Clearance::RackSession
- Inherits:
-
Object
- Object
- Clearance::RackSession
- Defined in:
- lib/clearance/rack_session.rb
Overview
Rack middleware that manages the Clearance Session. This middleware is automatically mounted by the Clearance Engine.
- maintains the session cookie specified by your Configuration.
- exposes previously cookied sessions to Clearance and your app at
request.env[:clearance]
, which Authentication#current_user pulls the user from.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Reads previously existing sessions from a cookie and maintains the cookie on each response.
-
#initialize(app) ⇒ RackSession
constructor
A new instance of RackSession.
Constructor Details
#initialize(app) ⇒ RackSession
Returns a new instance of RackSession.
14 15 16 |
# File 'lib/clearance/rack_session.rb', line 14 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Reads previously existing sessions from a cookie and maintains the cookie on each response.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/clearance/rack_session.rb', line 20 def call(env) session = Clearance::Session.new(env) env[:clearance] = session response = @app.call(env) if session.authentication_successful? session. end response end |