RefineryCMS:重写Devise Omniauth Callbacks

时间:2011-08-12 12:59:52

标签: devise omniauth refinerycms

我正在开发一个我希望通过我在不同服务器上设置的自定义oauth提供程序进行身份验证的应用程序。

我正在尝试使用RefineryCMS集成此自定义登录。我有我的路线设置,但由于某种原因,它仍然试图遵循RefineryCMS内置的设计路线。

的routes.rb

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
devise_scope :users do
 match '/users/auth/:provider', :to => 'users/omniauth_callbacks#passthru'
end

回拨链接

<p><%= link_to "Sign in with Olympus", user_omniauth_callback_path(:olympus) %></p>

奥林巴斯现在是该项目的代号。

Omniauth回调控制器:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def olympus
    auth = env["omniauth.auth"]
    ap auth
  end

  def passthru
    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
  end
end

点击链接后,通过rails登录日志:

Started GET "/users/auth/olympus/callback" for 127.0.0.1 at 2011-08-12 07:52:09 -0500
  Processing by Devise::OmniauthCallbacksController#failure as 
  SQL (0.7ms)  SHOW TABLES
  SQL (0.6ms)  SHOW TABLES
  Page Load (0.3ms)  SELECT `pages`.`id`, `pages`.`depth`, `pages`.`parent_id`, `pages`.`lft`, `pages`.`rgt`, `pages`.`link_url`, `pages`.`menu_match`, page_translations.title as page_title FROM `pages` INNER JOIN `page_translations` ON `page_translations`.`page_id` = `pages`.`id` WHERE `pages`.`draft` = 0 AND `pages`.`show_in_menu` = 1 AND `page_translations`.`locale` = 'en' ORDER BY lft ASC
  Slug Load (0.1ms)  SELECT `slugs`.* FROM `slugs` WHERE (`slugs`.`sluggable_id` IN (1,3) and `slugs`.`sluggable_type` = 'Page' AND (`slugs`.`locale` = 'en')) ORDER BY id DESC
  Slug Load (0.2ms)  SELECT `slugs`.* FROM `slugs` WHERE (`slugs`.sluggable_id = 3 AND `slugs`.sluggable_type = 'Page') ORDER BY id DESC
  SQL (1.3ms)  describe `roles_users`
  Role Load (0.1ms)  SELECT `roles`.* FROM `roles` WHERE `roles`.`title` = 'Refinery' LIMIT 1
  SQL (1.4ms)  describe `roles_users`
  User Load (0.2ms)  SELECT * FROM `users` INNER JOIN `roles_users` ON `users`.id = `roles_users`.user_id WHERE (`roles_users`.role_id = 1 )
Redirected to http://localhost:3000/users/login

所以它仍然试图通过RefineryCMS通过Devise :: OmniauthCallbacksController ...有谁知道如何解决这个问题,甚至可能覆盖这个设计控制器?

我还想说,我对与oauth提供商/客户合作完全陌生。我曾与Facebook和Twitter合作,但从头开始做这些我是新手。以及与Devise / Omniauth合作。请原谅我的无知。谢谢!

1 个答案:

答案 0 :(得分:0)

阅读本文修复了路由问题:http://groups.google.com/group/refinery-cms/browse_thread/thread/37917e227b26f5ca

我现在遇到的问题是,它似乎没有连接到我的oauth提供商进行身份验证:(