Sha256: d891b1e5f1e83ffc6cb5a9c0ae942601108be2bee2c4a2b2ea8095e99844cb4c

Contents?: true

Size: 578 Bytes

Versions: 5

Compression:

Stored size: 578 Bytes

Contents

Warden::Manager.after_set_user(except: :fetch) do |record, warden, options|
  if record.respond_to?(:password_sharing?) && warden.authenticated?(options[:scope])
    if handler = Devise.banning_handler
      handler.call(record, warden.request.remote_ip)
    else
      record.create_login_event!(warden.request.remote_ip)
      if record.password_sharing?
        record.ban_for_password_sharing!
        scope = options[:scope]
        warden.logout(scope)
        throw :warden, :scope => scope, :message => 'Account banned for password sharing.'
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
devise_password_sharing_extension-0.1.4 lib/devise_password_sharing_extension/hooks/password_sharing.rb
devise_password_sharing_extension-0.1.3 lib/devise_password_sharing_extension/hooks/password_sharing.rb
devise_password_sharing_extension-0.1.1 lib/devise_password_sharing_extension/hooks/password_sharing.rb
devise_password_sharing_extension-0.0.15 lib/devise_password_sharing_extension/hooks/password_sharing.rb
devise_password_sharing_extension-0.0.14 lib/devise_password_sharing_extension/hooks/password_sharing.rb