2017-12-21 17:36:29 +00:00
|
|
|
# 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.
|
2009-11-13 19:23:32 +00:00
|
|
|
Warden::Manager.after_set_user do |record, warden, options|
|
2011-03-25 14:39:08 +00:00
|
|
|
if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
|
2011-01-03 15:24:07 +00:00
|
|
|
scope = options[:scope]
|
|
|
|
warden.logout(scope)
|
2014-02-25 16:42:55 +00:00
|
|
|
throw :warden, scope: scope, message: record.inactive_message
|
2009-10-21 13:20:10 +00:00
|
|
|
end
|
2013-12-05 08:03:32 +00:00
|
|
|
end
|