From 2063d20e9a1e9e3a87d10c35ff5953f78f256c3d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 4 Jul 2019 10:06:18 +0100 Subject: [PATCH] Revert "DEV: Let OmniAuth strategies return auth result. (#7833)" This reverts commit dc5eb7655148742593257dbe690d829c264f26d2. It is better to keep any custom redirect logic within omniauth, without relying on the app --- .../users/omniauth_callbacks_controller.rb | 9 --------- .../omniauth_callbacks_controller_spec.rb | 20 ------------------- 2 files changed, 29 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 138481eca07..4a9b0916e2f 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -19,15 +19,6 @@ class Users::OmniauthCallbacksController < ApplicationController skip_before_action :verify_authenticity_token, only: :complete def complete - if result = request.env["omniauth.result"] - @auth_result = result - - return respond_to do |format| - format.html - format.json { render json: @auth_result.to_client_hash } - end - end - auth = request.env["omniauth.auth"] raise Discourse::NotFound unless request.env["omniauth.auth"] diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb index 1ed3284971c..0cb2d54a400 100644 --- a/spec/requests/omniauth_callbacks_controller_spec.rb +++ b/spec/requests/omniauth_callbacks_controller_spec.rb @@ -12,7 +12,6 @@ RSpec.describe Users::OmniauthCallbacksController do after do Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2] = nil - Rails.application.env_config["omniauth.result"] = nil OmniAuth.config.test_mode = false end @@ -80,25 +79,6 @@ RSpec.describe Users::OmniauthCallbacksController do end end - describe '.complete' do - it 'will return result if present' do - result = Auth::Result.new - result.user = Fabricate(:user) - result.authenticated = true - result.destination_url = "/anotherpath" - - Rails.application.env_config["omniauth.origin"] = '/somepath' - Rails.application.env_config["omniauth.result"] = result - - get "/auth/test/callback.json" - response_body = JSON.parse(response.body) - - expect(response.status).to eq(200) - expect(response_body["authenticated"]).to eq(true) - expect(response_body["destination_url"]).to eq("/anotherpath") - end - end - context 'Google Oauth2' do before do SiteSetting.enable_google_oauth2_logins = true