FEATURE: Allow linking an existing account during external-auth signup (PR #13960)

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 PR contains two other commits which clean up the backend implementation to make this possible. This PR is intended to be rebased & merged.

GitHub

This is a nice feature. The code looks good but I always feel uneasy reviewing auth code because it’s so important that it never breaks! We should deploy carefully and test quickly afterwards.

Are we able to make this method private since it does not need to be public and is not a controller action?

Does this need to be an instance variable instead of just a regular variable?

        get "/auth/google_oauth2/callback.json"
        expect(response.status).to eq(302)

Asserting for the response first helps make it easier to debug if the test fails in the future.

      it 'should return an associate url when multiple login methods are enabled' do

🤦 you’re right, it doesn’t need to be an instance variable. Will fix.

Sorry one more comment here. It doesn’t seem like we’re actually testing for the associate link in this test. I see in another we’re testing for the .create-account-associate-link class but we don’t test the existence of it in any of the other tests.

🤦 you’re right, I accidentally deleted the check when refactoring. Will fix