Skip to content

Instantly share code, notes, and snippets.

@mhfs
Created December 30, 2009 20:33
Show Gist options
  • Select an option

  • Save mhfs/266367 to your computer and use it in GitHub Desktop.

Select an option

Save mhfs/266367 to your computer and use it in GitHub Desktop.
# Each time a failed authentication attempt happens we call the lockable handlers
Warden::Manager.before_failure do |record, warden, options|
if record && record.respond_to?(:active?) && !record.active?
scope = options[:scope]
# If winning strategy was set, this is being called after authenticate and
# there is no need to force a redirect.
if warden.winning_strategy
warden.winning_strategy.fail!(record.inactive_message)
else
throw :warden, :scope => scope, :message => record.inactive_message
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment