docbrown/app/controllers/omniauth_callbacks_controller.rb
Mac Siri 40f488d991 Migrate to Travis CI (part 2) (#591)
* Update Travis.yml

* Update README

* Update README

* Adjust test to not rely on env vars

* Update encryption

* Refactor

* Update env key

* Stub AWS calls

* Create ApplicationConfig

* Fix specs

* Fix lint

* Update ApplicationConfig

* Remove travis env vars

* Fix lint

* Extend character limit to 100

* Add env to travis

* Take out auto-restart after deploy

* Immediately discarded test cache

* Stub GA in request specs

* Stub Pusher

* Fix broken specs

* Update fixture

* Add CodeClimate id

* Change CodeClimate key

* Remove merge mistakes

* WIP

* Add Envied gem & Change README

* Add missing keys

* Add missing key

* Update fixture

* Fix broken spec

* Add Slack Notification for Travis

* Fix wording

* Fix typo
2018-07-20 20:17:18 -04:00

25 lines
977 B
Ruby

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
# Don't need a policy for this since this is our sign up/in route
include Devise::Controllers::Rememberable
def self.provides_callback_for(provider)
# raise ApplicationConfig["omniauth.auth"].to_yaml
class_eval %{
def #{provider}
cta_variant = request.env["omniauth.params"]['state'].to_s
@user = AuthorizationService.new(request.env["omniauth.auth"], current_user, cta_variant).get_user
if @user.persisted?
remember_me(@user)
sign_in_and_redirect @user, event: :authentication
set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format?
else
session["devise.#{provider}_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
}
end
%i[twitter github].each do |provider|
provides_callback_for provider
end
end