Created
September 2, 2014 20:06
Revisions
-
jdanielnd created this gist
Sep 2, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ require 'devise/strategies/authenticatable' module Devise module Strategies class MixedAuthenticatable < Authenticatable def authenticate! authenticator.authenticate! end private def authenticator authenticator_factory.new(@env, @scope) end def authenticator_factory if user_requires_ldap_authentication LdapAuthenticatable else DatabaseAuthenticatable end end def user_requires_ldap_authentication if user = User.find_by_email(email) user.organization_requires_ldap? else false end end def email user_params[:email] end def user_params params[:user] end end end end Warden::Strategies.add(:mixed_authenticatable, Devise::Strategies::MixedAuthenticatable)