Search code examples
ruby-on-railsdeviseruby-on-rails-3.2omniauthrefinerycms

Devise + OmniAuth + Refinery CMS


We have used Devise + OmniAuth as authentication mechanism to authenticate user with facebook, twitter and openid. Now we need to integrate Refinery CMS into our existing application.

Requirement: The home page of application has Signup/Signin buttons with some static content. On Signing in, user is able to access restricted area. We want to add a link to access Refinery CMS on a restricted page. It should not ask for any credential again.

We followed following links to integrate Refinery CMS:

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

Now after starting server, when we hit http://localhost:3000 it redirects to http://localhost:3000/refinery/users/register. User should be able to see home page with public content. User can access refinery CMS(through /help) only after user authenticate himself with any supported services.

Here is snap of 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

We are beginner. Any help would be appreciable.


Solution

  • we followed http://sdownie.com/blogs/integrating-refinery-rails-3-2-into-your-existing-rails-app which worked.

    We had some issues which were discussed here.

    https://groups.google.com/d/topic/refinery-cms/G5twqi0uTHs/discussion https://groups.google.com/d/topic/refinery-cms/w-4VrfPewQY/discussion