Skip to content

Commit ddb828c

Browse files
committed
fix: new oauth users assigned to default org
1 parent 7059828 commit ddb828c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

coderd/userauth.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -1343,13 +1343,12 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13431343
if user.ID == uuid.Nil {
13441344
var organizationID uuid.UUID
13451345
//nolint:gocritic
1346-
organizations, _ := tx.GetOrganizations(dbauthz.AsSystemRestricted(ctx))
1347-
if len(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-
}
1346+
organization, _ := tx.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))
1347+
1348+
// Add the user to the default organization.
1349+
// Once multi-organization we should check some configuration to see
1350+
// if we should add the user to a different organization.
1351+
organizationID = organization.ID
13531352

13541353
//nolint:gocritic
13551354
_, err := tx.GetUserByEmailOrUsername(dbauthz.AsSystemRestricted(ctx), database.GetUserByEmailOrUsernameParams{
@@ -1395,7 +1394,7 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
13951394
// All of the userauth tests depend on this being able to create
13961395
// the first organization. It shouldn't be possible in normal
13971396
// operation.
1398-
CreateOrganization: len(organizations) == 0,
1397+
CreateOrganization: organizationID == uuid.Nil,
13991398
LoginType: params.LoginType,
14001399
})
14011400
if err != nil {

0 commit comments

Comments
 (0)