feat: use default org for PostUser (#12143)

Instead of assuming only 1 org exists, this uses the
is_default org to place a user in if not specified.
This commit is contained in:
Steven Masley
2024-02-16 08:28:36 -06:00
committed by GitHub
parent 0e1bad4f82
commit 2a8004b1b2
10 changed files with 101 additions and 13 deletions
+12
View File
@@ -1657,6 +1657,18 @@ func (q *FakeQuerier) GetDERPMeshKey(_ context.Context) (string, error) {
return q.derpMeshKey, nil
}
func (q *FakeQuerier) GetDefaultOrganization(_ context.Context) (database.Organization, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()
for _, org := range q.organizations {
if org.IsDefault {
return org, nil
}
}
return database.Organization{}, sql.ErrNoRows
}
func (q *FakeQuerier) GetDefaultProxyConfig(_ context.Context) (database.GetDefaultProxyConfigRow, error) {
return database.GetDefaultProxyConfigRow{
DisplayName: q.defaultProxyDisplayName,