質問

私は書く必要があるのカスタム認証のための戦略 https://github.com/plataformatec/devise があるという意docsに入ります。よう。

役に立ちましたか?

解決

そものスニペットに このスレッド の工夫googleグループ

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

以下の項目を追加すinitializers/工夫.rb

  config.warden do |manager| 
     manager.default_strategies.unshift :custom_strategy_name 
  end 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top