2010-05-16 08:13:43 -04:00
|
|
|
# Deny user access whenever his account is not active yet. All strategies that inherits from
|
2011-03-25 10:39:08 -04:00
|
|
|
# Devise::Strategies::Authenticatable and uses the validate already check if the user is active_for_authentication?
|
2010-05-16 08:13:43 -04:00
|
|
|
# before actively signing him in. However, we need this as hook to validate the user activity
|
|
|
|
# in each request and in case the user is using other strategies beside Devise ones.
|
2009-11-13 14:23:32 -05:00
|
|
|
Warden::Manager.after_set_user do |record, warden, options|
|
2011-03-25 10:39:08 -04:00
|
|
|
if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
|
2011-01-03 10:24:07 -05:00
|
|
|
scope = options[:scope]
|
|
|
|
warden.logout(scope)
|
|
|
|
throw :warden, :scope => scope, :message => record.inactive_message
|
2009-10-21 09:20:10 -04:00
|
|
|
end
|
2010-04-06 10:34:22 -04:00
|
|
|
end
|