FEATURE: Allow linking an existing account during external-auth signup

When a user signs up via an external auth method, a new link is added to the signup modal which allows them to connect an existing Discourse account. This will only happen if:

- There is at least 1 other auth method available

and

- The current auth method permits users to disconnect/reconnect their accounts themselves
This commit is contained in:
David Taylor
2021-08-02 17:57:52 +01:00
parent 46dc189850
commit 7dc8f8b794
7 changed files with 92 additions and 15 deletions

View File

@ -246,6 +246,19 @@ RSpec.describe Users::OmniauthCallbacksController do
expect(data["destination_url"]).to eq(destination_url)
end
it 'should return an associate url when multiple login methods are enabled' do
get "/auth/google_oauth2/callback.json"
expect(response.status).to eq(302)
data = JSON.parse(cookies[:authentication_data])
expect(data["associate_url"]).to start_with('/associate/')
SiteSetting.enable_local_logins = false
get "/auth/google_oauth2/callback.json"
data = JSON.parse(cookies[:authentication_data])
expect(data["associate_url"]).to eq(nil)
end
describe 'when site is invite_only' do
before do
SiteSetting.invite_only = true