mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
11 lines
No EOL
626 B
Ruby
11 lines
No EOL
626 B
Ruby
# Deny user access whenever his account is not active yet. All strategies that inherits from
|
|
# Devise::Strategies::Authenticatable and uses the validate already check if the user is active?
|
|
# 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.
|
|
Warden::Manager.after_set_user do |record, warden, options|
|
|
if record && record.respond_to?(:active?) && !record.active?
|
|
scope = options[:scope]
|
|
warden.logout(scope)
|
|
throw :warden, :scope => scope, :message => record.inactive_message
|
|
end
|
|
end |