mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Add organizations endpoint for users (#50)
* feat: Add organizations endpoint for users This moves the /user endpoint to /users/me instead. This will reduce code duplication. This adds /users/<name>/organizations to list organizations a user has access to. It doesn't contain the permissions a user has over the organizations, but that will come in a future contribution. * Fix requested changes * Fix tests * Fix timeout * Add test for UserOrgs * Add test for userparam getting * Add test for NoUser
This commit is contained in:
@ -31,15 +31,18 @@ func New(options *Options) http.Handler {
|
||||
Message: "👋",
|
||||
})
|
||||
})
|
||||
r.Post("/user", users.createInitialUser)
|
||||
r.Post("/login", users.loginWithPassword)
|
||||
// Require an API key and authenticated user for this group.
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(
|
||||
httpmw.ExtractAPIKey(options.Database, nil),
|
||||
httpmw.ExtractUser(options.Database),
|
||||
)
|
||||
r.Get("/user", users.authenticatedUser)
|
||||
r.Route("/users", func(r chi.Router) {
|
||||
r.Post("/", users.createInitialUser)
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(
|
||||
httpmw.ExtractAPIKey(options.Database, nil),
|
||||
httpmw.ExtractUserParam(options.Database),
|
||||
)
|
||||
r.Get("/{user}", users.user)
|
||||
r.Get("/{user}/organizations", users.userOrganizations)
|
||||
})
|
||||
})
|
||||
})
|
||||
r.NotFound(site.Handler().ServeHTTP)
|
||||
|
Reference in New Issue
Block a user