FIX: Return authenticated=true when reconnecting

FIX: Return authenticated=true when reconnecting

This prevents a registration popup on the client

From 0f734e2ae28caabca2d1fb5b17f5bfc0cdf6b4f4 Mon Sep 17 00:00:00 2001
From: David Taylor <david@taylorhq.com>
Date: Tue, 11 Dec 2018 17:40:02 +0000
Subject: [PATCH] FIX: Return authenticated=true when reconnecting

This prevents a registration popup on the client

diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
index b34e751..60bb229 100644
--- a/app/controllers/users/omniauth_callbacks_controller.rb
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -32,6 +32,7 @@ class Users::OmniauthCallbacksController < ApplicationController
         cookies.delete('fsl')
         return redirect_to Discourse.base_uri("/my/preferences/account")
       else
+        @auth_result.authenticated = true
         return respond_to do |format|
           format.html
           format.json { render json: @auth_result.to_client_hash }
diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb
index 97bd64b..d4b4243 100644
--- a/spec/requests/omniauth_callbacks_controller_spec.rb
+++ b/spec/requests/omniauth_callbacks_controller_spec.rb
@@ -412,6 +412,7 @@ RSpec.describe Users::OmniauthCallbacksController do
         OmniAuth.config.mock_auth[:google_oauth2].uid = "123456"
         get "/auth/google_oauth2/callback.json"
         expect(response.status).to eq(200)
+        expect(JSON.parse(response.body)["authenticated"]).to eq(true)
         expect(session[:current_user_id]).to eq(user.id)
         expect(GoogleUserInfo.count).to eq(1)
       end

GitHub

1 Like