Sha256: a50293d9eed38a8da5dccffd2e0cf9f399b5aba1ae8027641665ca580647e9e0
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'devise/strategies/authenticatable' module Devise module Strategies # Strategy for signing in a user based on his login and password using LDAP. # Redirects to sign_in page if it's not authenticated class LdapAuthenticatable < Authenticatable def valid? valid_controller? && valid_params? && mapping.to.respond_to?(:authenticate_with_ldap) end # Authenticate a user based on login and password params, returning to warden # success and the authenticated user if everything is okay. Otherwise redirect # to sign in page. def authenticate! if resource = mapping.to.authenticate_with_ldap(params[scope]) success!(resource) else fail(:invalid) end end protected def valid_controller? params[:controller] == mapping.controllers[:sessions] end def valid_params? params[scope] && params[scope][:password].present? end end end end Warden::Strategies.add(:ldap_authenticatable, Devise::Strategies::LdapAuthenticatable)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
charanya-devise_ldap_authenticatable-0.4.6.1 | lib/devise_ldap_authenticatable/strategy.rb |
charanya-devise_ldap_authenticatable-0.4.6 | lib/devise_ldap_authenticatable/strategy.rb |