heartcombo--devise/lib/devise/hooks/activatable.rb

13 lines
520 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2014-06-06 11:03:53 +00:00
# Deny user access whenever their account is not active yet.
# We need this as hook to validate the user activity on 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_for_authentication?) && !record.active_for_authentication?
scope = options[:scope]
warden.logout(scope)
2014-02-25 16:42:55 +00:00
throw :warden, scope: scope, message: record.inactive_message
end
2013-12-05 08:03:32 +00:00
end