2010-11-19 12 views

risposta

38

Ho trovato questo frammento molto utile nel this thread sul gruppo escogitare google

inizializzatori/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 

add seguente per inizializzatori/devise.rb

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

grazie, molto utile, l'ho usato per autenticare gli utenti di joomla del mio vecchio sito :-) – simo

+0

Risposta molto utile, il collegamento è rotto però. Potresti correggerlo? – mrzasa

+1

Il collegamento funziona ancora per me. – opsb

Problemi correlati