Skip to content

Commit

Permalink
Simplify oauth callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharydenton authored and aptos-bot committed May 7, 2022
1 parent 1a4622e commit 3ca629e
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def oauth_callback(provider)
@user = User.from_omniauth(auth_data, current_user)

if @user.persisted?
sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
set_flash_message(:notice, :success, kind: provider.to_s.titleize) if is_navigational_format?
else
# TODO: make this bulletproof
raise 'Unable to persist user'
end
# TODO: make this bulletproof
raise 'Unable to persist user' unless @user.persisted?

sign_in_and_redirect @user
set_flash_message(:notice, :success, kind: provider.to_s.titleize) if is_navigational_format?
end

def auth_data
Expand Down

0 comments on commit 3ca629e

Please sign in to comment.