2009-10-21 11:20:10 -02:00
|
|
|
# Each time the user is set we verify if it is still able to really sign in.
|
|
|
|
# This is done by checking the time frame the user is able to sign in without
|
|
|
|
# confirming it's account. If the user has not confirmed it's account during
|
|
|
|
# this time frame, he/she will not able to sign in anymore.
|
2009-11-13 17:23:32 -02:00
|
|
|
Warden::Manager.after_set_user do |record, warden, options|
|
2009-10-23 00:54:42 -02:00
|
|
|
if record && record.respond_to?(:active?) && !record.active?
|
2009-10-21 11:20:10 -02:00
|
|
|
scope = options[:scope]
|
2009-11-13 17:23:32 -02:00
|
|
|
warden.logout(scope)
|
2009-12-20 13:53:53 +01:00
|
|
|
|
|
|
|
# If winning strategy was set, this is being called after authenticate and
|
|
|
|
# there is no need to force a redirect.
|
2009-11-16 14:31:09 -02:00
|
|
|
if warden.winning_strategy
|
2009-12-20 13:53:53 +01:00
|
|
|
warden.winning_strategy.fail!(record.inactive_message)
|
2009-11-16 14:31:09 -02:00
|
|
|
else
|
2009-12-20 13:53:53 +01:00
|
|
|
throw :warden, :scope => scope, :message => record.inactive_message
|
2009-11-16 14:31:09 -02:00
|
|
|
end
|
2009-10-21 11:20:10 -02:00
|
|
|
end
|
|
|
|
end
|