将omniauth失败设计为自定义控制器

时间:2018-12-14 19:41:30

标签: ruby-on-rails devise omniauth

我有一个用于omniauth_callbacks的自定义控制器

class People::OmniauthCallbacksController < 
    Devise::OmniauthCallbacksController
 def setup
   ...
 end

 def facebook
   ...
 end

 def google-oauth2
   ...
 end

 def failure
  ...
 end
end

在路线上:

...
devise_for :people, only: :omniauth_callbacks, controllers: { omniauth_callbacks: 'people/omniauth_callbacks' }
devise_scope :person do
  get '/people/auth/:provider/setup' => 'people/omniauth_callbacks#setup' #needed for devise setup phase hook to work
end
...

当我通过omniauth进行身份验证失败时,我会得到: Processing by Devise::OmniauthCallbacksController#failure 但是我要处理People::OmniauthCallbacksController。我该如何设置?

设计(4.5.0) omn​​iauth(1.8.1) 导轨(4.2.5.2)

1 个答案:

答案 0 :(得分:0)

我认为问题是您的devise_scope,您应该使用:

devise_scope :people do
  get '/people/auth/:provider/setup' => 'people/omniauth_callbacks#setup' #needed for devise setup phase hook to work
end