Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert then fix diff
  • Loading branch information
Emyrk committed Feb 15, 2024
commit bf35196e6b15e9fdb4463bbabcff8bfe3d10d114
15 changes: 7 additions & 8 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,13 +1343,12 @@ func (api *API) oauthLogin(r *http.Request, params *oauthLoginParams) ([]*http.C
if user.ID == uuid.Nil {
var organizationID uuid.UUID
//nolint:gocritic
organizations, _ := tx.GetOrganizations(dbauthz.AsSystemRestricted(ctx))
if len(organizations) > 0 {
// Add the user to the first organization. Once multi-organization
// support is added, we should enable a configuration map of user
// email to organization.
organizationID = organizations[0].ID
}
organization, _ := tx.GetDefaultOrganization(dbauthz.AsSystemRestricted(ctx))

// Add the user to the default organization.
// Once multi-organization we should check some configuration to see
// if we should add the user to a different organization.
organizationID = organization.ID

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