-
Notifications
You must be signed in to change notification settings - Fork 943
chore: ensure default org always exists #12412
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e4b1bb8
b4a4dd4
627c9f8
179828c
db8da5a
b830625
6b086c6
9997f59
3977c71
d35933d
1b8690f
c9af8c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import ( | |
"github.com/google/uuid" | ||
"golang.org/x/xerrors" | ||
|
||
"cdr.dev/slog" | ||
"github.com/coder/coder/v2/coderd/audit" | ||
"github.com/coder/coder/v2/coderd/database" | ||
"github.com/coder/coder/v2/coderd/database/db2sdk" | ||
|
@@ -196,10 +197,9 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) { | |
//nolint:gocritic // needed to create first user | ||
user, organizationID, err := api.CreateUser(dbauthz.AsSystemRestricted(ctx), api.Database, CreateUserRequest{ | ||
CreateUserRequest: codersdk.CreateUserRequest{ | ||
Email: createUser.Email, | ||
Username: createUser.Username, | ||
Password: createUser.Password, | ||
// Create an org for the first user. | ||
Email: createUser.Email, | ||
Username: createUser.Username, | ||
Password: createUser.Password, | ||
OrganizationID: defaultOrg.ID, | ||
}, | ||
CreateOrganization: false, | ||
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. I think you can remove this field, which also allows cleaning up a lot of cruft in userauth.go 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. Oh you are right. I think we can drop the |
||
|
@@ -1083,6 +1083,11 @@ func (api *API) userRoles(rw http.ResponseWriter, r *http.Request) { | |
|
||
uid, err := uuid.Parse(orgID) | ||
if err != nil { | ||
api.Logger.Critical(r.Context(), "org role contains invalid uuid", | ||
slog.F("username", user.Username), | ||
slog.F("user_id", user.ID.String()), | ||
slog.F("role", role), | ||
) | ||
continue // This should never happen | ||
Emyrk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if _, ok := allowedOrgs[uid]; ok { | ||
|
Uh oh!
There was an error while loading. Please reload this page.