我使用Omniauth作为我唯一的身份验证,我的模型上没有:database_authentication
。我想通过Atlassian人群登录使用这个宝石:https://github.com/robdimarco/omniauth_crowd如何使用Devise为Omniauth制作自定义登录表单?
该宝石使用标准的Crowd登录表单,我不想要。我想制作一个自定义表单,其行为方式相同,但完全取代了登录页面(没有“用人群登录”)或类似的东西,只是登录到Crowd的表单。
要做到这一点,我在devise.rb添加了这个选项我config.omniauth
线:
:form => Devise::SessionsController.actions(:new)
其中,从我可以在网上看到,将使用该架端点显示自定义表单。我已经改变了HTML在app /视图/设计/会话/ new.html.erb到new.html.haml,其中包含这种形式:
= simple_form_for @user, :url => user_omniauth_authorize_path(:crowd) do |f|
= f.input :username, :input_html => { :name => 'username' }
= f.input :password, :input_html => { :name => 'password' }
= f.button :submit
对此我用模拟的默认OmniAuth形式希望。问题是,当我访问用户/ auth /中的人群,在我devise.rb的:form
选项,我得到的错误:使用时
Could not find devise mapping for path "https://stackoverflow.com/users/auth/crowd".
是否有提供自定义表单OmniAuth这样的方式设计?
编辑:这里是路线:
devise_for :users, :controllers => { :omniauth_callbacks => 'users/omniauth' } do
get 'login', :to => 'devise/sessions#new', :as => :new_user_session
get 'logout', :to => 'devise/sessions#destroy', :as => :destroy_user_session
end
devise_scope :user do
get '/users/auth/:provider', :to => 'users/omniauth#passthru'
match '/users/auth/failure', :to => 'users/omniauth#failure'
end
resources :users
我在这里尝试了几件事情,但没有什么我已经试过了工作。
如何你的路由定义? – Ashitaka
用我的路线编辑。 –
你给你的omniauth控制器起什么名字? '用户:: OmniauthController'?它在名为'users'的文件夹内吗?该控制器中定义的操作是什么? – Ashitaka