Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Show all possible external connections in Account security. Only allo…#42865

Merged
pjlast merged 7 commits intomainfrom
pjlast/38195-multiple-external-accounts
Oct 12, 2022
Merged

Show all possible external connections in Account security. Only allo…#42865
pjlast merged 7 commits intomainfrom
pjlast/38195-multiple-external-accounts

Conversation

@pjlast
Copy link
Contributor

@pjlast pjlast commented Oct 12, 2022

Solves #38195 and then some

Display all possible external service connections in user's Account Security page. Had to rework a lot of functions, because a lot of them assumed there would only be one provider per type, however, you can have multiple hosts of the same type. So now, instead, we use the auth provider's Service ID (the base URL) as the unique identifier, and we display config errors appropriately when more than one that uses the same URL is used. This is long overdue, as it would have caused undefined behaviour in some parts of the code anyways, when random auth providers are selected.

Further more, I made it so that the user's "Change Password" fields are visible even if they have external accounts, because signing in with a username and password is still valid.

image

image

Test plan

Updated unit tests

@sg-e2e-regression-test-bob
Copy link

sg-e2e-regression-test-bob commented Oct 12, 2022

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) 0.00% (+0.14 kb) 0.00% (+0.14 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits 447af6c and 288371b or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

Copy link
Contributor

@kopancek kopancek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, small improvements suggested.

@@ -81,19 +79,11 @@ export const UserSettingsSecurityPage: React.FunctionComponent<React.PropsWithCh
}

// auth providers by service type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// auth providers by service type
// auth providers by serviceID

Comment on lines +202 to +204
<H3 className="mb-3">Password</H3>
<Container>
<Form onSubmit={handleSubmit}>
Copy link
Contributor

@kopancek kopancek Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be more specific here and specify the action in the header, similar as we do in the button at the end of the form.

Suggested change
<H3 className="mb-3">Password</H3>
<Container>
<Form onSubmit={handleSubmit}>
<H3 className="mb-3">{props.user.builtinAuth ? 'Update ' : 'Create '}Password</H3>
<Container>
<Form onSubmit={handleSubmit}>

I would also add a description to this section, because on the screenshot it looks weird. E.g. something like (to be confirmed by @ryphil or someone with better language skills than me):

<p>Create a password for this user account on the <a href="docs">built-in username/password authentication.</a> This will allow the current user to login with username `{user.username}` and password in the future.</p>

And a similar one for the password change:

<p>Change password for this user account on the <a href="docs">built-in username/password authentication.</a></p>

Otherwise users might be confused as to which password they are going to create/change.

Copy link
Contributor

@kopancek kopancek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better 👍

@pjlast pjlast marked this pull request as ready for review October 12, 2022 12:01
@pjlast pjlast requested a review from mrnugget October 12, 2022 12:01
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Oct 12, 2022

Codenotify: Notifying subscribers in CODENOTIFY files for diff 288371b...447af6c.

Notify File(s)
@unknwon enterprise/cmd/frontend/internal/auth/githuboauth/config.go
enterprise/cmd/frontend/internal/auth/githuboauth/config_test.go
enterprise/cmd/frontend/internal/auth/gitlaboauth/config.go
enterprise/cmd/frontend/internal/auth/gitlaboauth/config_test.go

Copy link
Contributor

@unknwon unknwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not look very close, thanks for fixing this!

alreadyExists := false
for _, p := range ps {
if p.CachedInfo().ServiceID == provider.ServiceID {
problems = append(problems, conf.NewSiteProblems(fmt.Sprintf("cannot have more than one auth provider with url '%s', only the first one will be used", provider.ServiceID))...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
problems = append(problems, conf.NewSiteProblems(fmt.Sprintf("cannot have more than one auth provider with url '%s', only the first one will be used", provider.ServiceID))...)
problems = append(problems, conf.NewSiteProblems(fmt.Sprintf(`Cannot have more than one auth provider with url %q, only the first one will be used`, provider.ServiceID))...)

alreadyExists := false
for _, p := range ps {
if p.CachedInfo().ServiceID == provider.ServiceID {
problems = append(problems, conf.NewSiteProblems(fmt.Sprintf("cannot have more than one auth provider with url '%s', only the first one will be used", provider.ServiceID))...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on nit

Copy link
Contributor

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big QoL improvement!

@pjlast pjlast merged commit d1822e0 into main Oct 12, 2022
@pjlast pjlast deleted the pjlast/38195-multiple-external-accounts branch October 12, 2022 13:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants