소스 검색

Clean up omniauth callbacks

We will likely want custom omniauth implementations, so keep these
redundant methods for now.
Andrew Swistak 5 년 전
부모
커밋
e7a94df1c8
1개의 변경된 파일5개의 추가작업 그리고 13개의 파일을 삭제
  1. 5 13
      app/controllers/omniauth_callbacks_controller.rb

+ 5 - 13
app/controllers/omniauth_callbacks_controller.rb

@@ -23,11 +23,7 @@ class OmniauthCallbacksController < ApplicationController
     @user = User.from_omniauth(request.env['omniauth.auth'])
 
     if @user.persisted?
-      # this will throw if @user is not activated
       sign_in_and_redirect @user, event: :authentication
-      # if is_navigational_format?
-      #  set_flash_message(:notice, :success, kind: 'Google')
-      # end
     else
       redirect_to new_user_registration_url
     end
@@ -37,11 +33,7 @@ class OmniauthCallbacksController < ApplicationController
     @user = User.from_omniauth(request.env['omniauth.auth'])
 
     if @user.persisted?
-      # this will throw if @user is not activated
       sign_in_and_redirect @user, event: :authentication
-      # if is_navigational_format?
-      #  set_flash_message(:notice, :success, kind: 'Reddit')
-      # end
     else
       redirect_to new_user_registration_url
     end
@@ -51,20 +43,20 @@ class OmniauthCallbacksController < ApplicationController
     @user = User.from_omniauth(request.env['omniauth.auth'])
 
     if @user.persisted?
-      # this will throw if @user is not activated
       sign_in_and_redirect @user, event: :authentication
-      # if is_navigational_format?
-      #  set_flash_message(:notice, :success, kind: 'Discord')
-      # end
     else
       redirect_to new_user_registration_url
     end
   end
 
   def sign_in_and_redirect(user, *_args)
+    # TODO: Log event
+    # TODO: Throw on unregistered/unknown user
+
     # Ensure we have a new CSRF token now that user is signed in
     cookies.delete(:_csrf_token)
-    self.current_user = user
+
+    login(user)
     cookies['x-csrf-token'] = {
       value: form_authenticity_token,
       httponly: false,