Class: Devise::Middlewares::Rememberable

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/middlewares/rememberable.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Rememberable

Returns a new instance of Rememberable.



4
5
6
# File 'lib/devise/middlewares/rememberable.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/devise/middlewares/rememberable.rb', line 8

def call(env)
  auth = env['warden']
  scopes = select_cookies(auth.request)
  scopes.each do |scope, token|
    mapping = Devise.mappings[scope]
    next unless mapping && mapping.for.include?(:rememberable)
    user = mapping.to.serialize_from_cookie(token)
    auth.set_user(user, :scope => scope) if user
  end

  @app.call(env)
end