2010-11-19 10 views

Respuesta

38

me encontré con este fragmento muy útil en la this thread en el grupo legado Google

inicializadores/some_initializer.rb:

Warden::Strategies.add(:custom_strategy_name) do 
    def valid? 
    # code here to check whether to try and authenticate using this strategy; 
    return true/false 
    end 

    def authenticate! 
    # code here for doing authentication; 
    # if successful, call 
    success!(resource) # where resource is the whatever you've authenticated, e.g. user; 
    # if fail, call 
    fail!(message) # where message is the failure message 
    end 
end 

complemento siguiente para inicializadores/devise.rb

config.warden do |manager| 
    manager.default_strategies.unshift :custom_strategy_name 
    end 
+1

gracias, muy útil, lo he usado para autenticar a los usuarios joomla de mi antiguo sitio web :-) – simo

+0

Respuesta muy útil, aunque el enlace está roto. ¿Podrías corregirlo? – mrzasa

+1

El enlace todavía funciona para mí. – opsb

Cuestiones relacionadas