Skip to content

Commit b8899d5

Browse files
committed
chore: although unfortunate, it is possible for a user to be in no orgs
1 parent 49d6d0f commit b8899d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,9 +3006,6 @@ func (q *FakeQuerier) GetOrganizationIDsByMemberIDs(_ context.Context, ids []uui
30063006
OrganizationIDs: userOrganizationIDs,
30073007
})
30083008
}
3009-
if len(getOrganizationIDsByMemberIDRows) == 0 {
3010-
return nil, sql.ErrNoRows
3011-
}
30123009
return getOrganizationIDsByMemberIDRows, nil
30133010
}
30143011

coderd/users.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,9 +1293,12 @@ func userOrganizationIDs(ctx context.Context, api *API, user database.User) ([]u
12931293
if err != nil {
12941294
return []uuid.UUID{}, err
12951295
}
1296+
1297+
// If you are in no orgs, then return an empty list.
12961298
if len(organizationIDsByMemberIDsRows) == 0 {
1297-
return []uuid.UUID{}, xerrors.Errorf("user %q must be a member of at least one organization", user.Email)
1299+
return []uuid.UUID{}, nil
12981300
}
1301+
12991302
member := organizationIDsByMemberIDsRows[0]
13001303
return member.OrganizationIDs, nil
13011304
}

0 commit comments

Comments
 (0)