diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 6b9004b4..61b4088f 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,13 +1,14 @@ -class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController - skip_before_filter :verify_authenticity_token +module Users + class OmniauthCallbacksController < Devise::OmniauthCallbacksController + skip_before_filter :verify_authenticity_token - [:novell, :google, :facebook, :twitter].each do |provider| - define_method(provider) { handle(provider) } - end + [:novell, :google, :facebook, :twitter].each do |provider| + define_method(provider) { handle(provider) } + end + + private - private def handle(provider) - auth_hash = request.env['omniauth.auth'] openid = Openid.find_for_oauth(auth_hash) # Get or create openid # If openid exists and is associated with a user, sign in with associated user, @@ -29,4 +30,5 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message end end -end \ No newline at end of file + end +end diff --git a/app/models/datatable_supporters.rb b/app/models/datatable_supporters.rb index 5c762c59..dc51d612 100644 --- a/app/models/datatable_supporters.rb +++ b/app/models/datatable_supporters.rb @@ -37,4 +37,4 @@ class DatatableSupporters < Datatable def columns ["name", "email", "name", "name", "name"] end -end \ No newline at end of file +end diff --git a/app/models/openid.rb b/app/models/openid.rb index b85a1525..2795cd44 100644 --- a/app/models/openid.rb +++ b/app/models/openid.rb @@ -1,6 +1,6 @@ class Openid < ActiveRecord::Base belongs_to :user - validates :provider, :uid, :presence => true + validates :provider, :uid, presence: true # Searches for openid based on provider and uid. # Returns found openid or a new openid. @@ -16,7 +16,5 @@ class Openid < ActiveRecord::Base end end openid - end - end diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 9e9ef482..ba36e45a 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -63,9 +63,9 @@ feature Openid do expect(Openid.where(email: 'test-1@gmail.com').first.nil?).to eq(false) end - it 'signs in with openID using the same email as another associated openid' do |user| + it 'signs in with openID using the same email as another associated openid' do # Sign in user - user = create(:participant, email: 'test-participant-1@google.com') + create(:participant, email: 'test-participant-1@google.com') expected_count_openid = Openid.count + 1 expected_count_user = User.count visit '/accounts/sign_in'