1

我們使用Devise + OmniAuth作爲身份驗證機制,通過facebook,twitter和openid對用戶進行身份驗證。現在我們需要將煉油CMS集成到我們現有的應用程序中。Devise + OmniAuth + Refinery CMS

要求: 應用程序的主頁上有一些靜態內容註冊/登入按鈕。登錄時,用戶可以訪問受限區域。我們希望添加一個鏈接,以便在受限制的頁面上訪問煉油廠CMS。它不應再要求任何憑證。

我們遵循以下鏈接整合煉油廠CMS:

  1. http://refinerycms.com/guides/with-an-existing-rails-app
  2. http://refinerycms.com/guides/with-an-existing-rails-31-devise-app

現在啓動服務器,當我們打http://localhost:3000它重定向到http://localhost:3000/refinery/users/register後。用戶應該能夠看到帶有公共內容的主頁。只有在用戶使用任何支持的服務對自己進行身份驗證後,用戶才能訪問煉油廠CMS(通過/幫助)。

這裏是的config/routes.rb中

mount Refinery::Core::Engine, :at => '/' 
... 
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", registrations: "registrations" } 
.... 
root :to => "home#index" 

的config/application.rb中

config.autoload_paths += Dir["#{config.root}/lib/**/"] # to load files from lib directory, including subfolders 

    config.before_initialize do 
     require 'refinery_patch' 
     require 'restrict_refinery_to_refinery_users' 
    end 

    include Refinery::Engine 
    after_inclusion do 
     [ApplicationController, ApplicationHelper].each do |c| 
     c.send :include, ::RefineryPatch 
     end 

     ::Refinery::AdminController.send :include, ::RestrictRefineryToRefineryUsers 
     ::Refinery::AdminController.send :before_filter, :restrict_refinery_to_refinery_users 
    end 

我們是初學者輕而易舉。任何幫助將是可觀的。

回答

相關問題