Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75870c2

Browse files
authored
fix: assign new oauth users to default org (#12145)
* fix: assign new oauth users to default orgThis is not a final solution, as we eventually want to be ableto map to different orgs. This makes it so multi-org does not break oauth/oidc.
1 parent2a8004b commit75870c2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

‎coderd/userauth.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,14 +1342,16 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13421342
// with OIDC for the first time.
13431343
ifuser.ID==uuid.Nil {
13441344
varorganizationID uuid.UUID
1345+
// Ignoring this error is a product of our unit tests. In prod this should never
1346+
// happen. Unit tests use this as a shortcut to making a new organization. We
1347+
// should really fix our unit tests and remove this.
13451348
//nolint:gocritic
1346-
organizations,_:=tx.GetOrganizations(dbauthz.AsSystemRestricted(ctx))
1347-
iflen(organizations)>0 {
1348-
// Add the user to the first organization. Once multi-organization
1349-
// support is added, we should enable a configuration map of user
1350-
// email to organization.
1351-
organizationID=organizations[0].ID
1352-
}
1349+
organization,_:=tx.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))
1350+
1351+
// Add the user to the default organization.
1352+
// Once multi-organization we should check some configuration to see
1353+
// if we should add the user to a different organization.
1354+
organizationID=organization.ID
13531355

13541356
//nolint:gocritic
13551357
_,err:=tx.GetUserByEmailOrUsername(dbauthz.AsSystemRestricted(ctx), database.GetUserByEmailOrUsernameParams{
@@ -1395,7 +1397,7 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13951397
// All of the userauth tests depend on this being able to create
13961398
// the first organization. It shouldn't be possible in normal
13971399
// operation.
1398-
CreateOrganization:len(organizations)==0,
1400+
CreateOrganization:organizationID==uuid.Nil,
13991401
LoginType:params.LoginType,
14001402
})
14011403
iferr!=nil {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp