Skip to content

Instantly share code, notes, and snippets.

@cmorss
Created March 3, 2020 17:29
Show Gist options
  • Save cmorss/7f2f8da39a3fd26fbde90fc326294b28 to your computer and use it in GitHub Desktop.
Save cmorss/7f2f8da39a3fd26fbde90fc326294b28 to your computer and use it in GitHub Desktop.
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def google_oauth2
auth = request.env['omniauth.auth']
manager = Manager.where(provider: auth['provider'], uid: auth['uid'])
.first_or_initialize(email: auth['info']['email'])
manager.first_name = auth['info']['first_name']
manager.last_name = auth['info']['last_name']
manager.save!
manager.remember_me = true
sign_in(:manager, manager)
Salesforce::LinkManagerJob.perform_later(manager.id) unless manager.salesforce_user_id
redirect_to manage_learners_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment