1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Decouple validation from remember_me in authentication strategies

Closes #3118
This commit is contained in:
José Valim 2014-09-18 20:04:05 +02:00
parent 73c406b481
commit 7029a5aaa8
3 changed files with 8 additions and 5 deletions

View file

@ -36,7 +36,6 @@ module Devise
result = resource && resource.valid_for_authentication?(&block)
if result
decorate(resource)
true
else
if resource
@ -47,7 +46,7 @@ module Devise
end
# Get values from params and set in the resource.
def decorate(resource)
def remember_me(resource)
resource.remember_me = remember_me? if resource.respond_to?(:remember_me=)
end

View file

@ -9,6 +9,7 @@ module Devise
encrypted = false
if validate(resource){ encrypted = true; resource.valid_password?(password) }
remember_me(resource)
resource.after_database_authentication
success!(resource)
end

View file

@ -25,15 +25,18 @@ module Devise
end
if validate(resource)
remember_me(resource)
extend_remember_me_period(resource)
success!(resource)
end
end
private
def decorate(resource)
super
resource.extend_remember_period = mapping.to.extend_remember_period if resource.respond_to?(:extend_remember_period=)
def extend_remember_me_period(resource)
if resource.respond_to?(:extend_remember_period=)
resource.extend_remember_period = mapping.to.extend_remember_period
end
end
def remember_me?