- Notifications
You must be signed in to change notification settings - Fork928
feat: use default org for PostUser#12143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1016,6 +1016,12 @@ func (q *querier) GetDERPMeshKey(ctx context.Context) (string, error) { | ||
return q.db.GetDERPMeshKey(ctx) | ||
} | ||
func (q *querier) GetDefaultOrganization(ctx context.Context) (database.Organization, error) { | ||
return fetch(q.log, q.auth, func(ctx context.Context, _ any) (database.Organization, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. No need for auth here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. That does do auth! | ||
return q.db.GetDefaultOrganization(ctx) | ||
})(ctx, nil) | ||
} | ||
func (q *querier) GetDefaultProxyConfig(ctx context.Context) (database.GetDefaultProxyConfigRow, error) { | ||
// No authz checks | ||
return q.db.GetDefaultProxyConfig(ctx) | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -401,23 +401,26 @@ func (api *API) postUser(rw http.ResponseWriter, r *http.Request) { | ||
return | ||
} | ||
} else { | ||
// If no organization is provided, add the user to the default | ||
defaultOrg, err := api.Database.GetDefaultOrganization(ctx) | ||
if err != nil { | ||
if httpapi.Is404Error(err) { | ||
httpapi.Write(ctx, rw, http.StatusNotFound, | ||
codersdk.Response{ | ||
Message: "Resource not found or you do not have access to this resource", | ||
Detail: "Organization not found", | ||
}, | ||
) | ||
return | ||
} | ||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ | ||
Message: "Internal error fetching orgs.", | ||
Detail: err.Error(), | ||
}) | ||
return | ||
} | ||
req.OrganizationID = defaultOrg.ID | ||
Comment on lines -404 to +423 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is the change | ||
} | ||
var loginType database.LoginType | ||