2

Heroku で omniauth-identity を使用してログインを管理しています。Omniauth は、ID コールバックの環境でセットアップされていません。

class SessionsController < ApplicationController

. . . 

private

  def omniauth
    fail "No omniauth in environment" unless request.env["omniauth.auth"] || session[:omniauth]
    request.env["omniauth.auth"] || session[:omniauth]
  end

end

案の定、失敗します:

2012-05-31T20:46:56+00:00 app[web.1]: Started POST "/auth/identity/callback" for 74.192.34.328 at 2012-05-31 20:46:56 +0000
2012-05-31T20:46:56+00:00 app[web.1]:   app/controllers/sessions_controller.rb:58:in `omniauth'
2012-05-31T20:46:56+00:00 app[web.1]:   app/controllers/sessions_controller.rb:6:in `create'
2012-05-31T20:46:56+00:00 app[web.1]: RuntimeError (No omniauth in environment):

どうにかして Heroku をセットアップする必要がありますか? それは開発で動作します。


編集:

# Gemfile
source 'http://rubygems.org'

gem 'anjlab-bootstrap-rails', '>= 2.0', :require => 'bootstrap-rails'
gem 'bcrypt-ruby', :require => 'bcrypt'
gem "cancan"
gem 'copies_omniauth'
gem "jquery-rails"
gem 'omniauth'
gem 'omniauth-browserid'
gem 'omniauth-facebook'
gem 'omniauth-identity'
gem 'omniauth-twitter'
gem 'quantity'
gem 'rails', '>=3.2.0'
gem "state_machine"

group :assets do
  gem 'sass-rails', "  >= 3.2.0"
end

group :development do
  gem 'faker'
  gem 'rspec-rails'
  gem "sqlite3"
end

group :test do
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'guard'
  gem 'guard-bundler'
  gem 'guard-rails-assets'
  gem 'guard-rspec'
  gem 'spork'
  gem "sqlite3"
end

group :production do
  gem 'thin'
  gem 'pg'
end

# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  # https://developers.facebook.com/apps/445087828841937
  provider :facebook, ENV['FACEBOOK_ID'], ENV['FACEBOOK_SECRET']

  # https://dev.twitter.com/apps/1568910/show
  provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']

  # https://github.com/intridea/omniauth-identity
  # http://railscasts.com/episodes/304-omniauth-identity?view=asciicast
  provider :identity, :fields => [:email], :model => AccountPassword,
           on_failed_registration: lambda { |env| AccountPasswordsController.action(:new).call(env) }

end
4

0 に答える 0