mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08: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:
@@ -41,6 +41,14 @@ SELECT
|
||||
FROM
|
||||
users;
|
||||
|
||||
-- name: GetOrganizationByName :one
|
||||
SELECT * FROM organizations WHERE name = $1 LIMIT 1;
|
||||
|
||||
-- name: GetOrganizationsByUserID :many
|
||||
SELECT * FROM organizations WHERE id = (
|
||||
SELECT organization_id FROM organization_members WHERE user_id = $1
|
||||
);
|
||||
|
||||
-- name: InsertAPIKey :one
|
||||
INSERT INTO
|
||||
api_keys (
|
||||
@@ -79,6 +87,12 @@ VALUES
|
||||
$15
|
||||
) RETURNING *;
|
||||
|
||||
-- name: InsertOrganization :one
|
||||
INSERT INTO organizations (id, name, description, created_at, updated_at) VALUES ($1, $2, $3, $4, $5) RETURNING *;
|
||||
|
||||
-- name: InsertOrganizationMember :one
|
||||
INSERT INTO organization_members (organization_id, user_id, created_at, updated_at, roles) VALUES ($1, $2, $3, $4, $5) RETURNING *;
|
||||
|
||||
-- name: InsertUser :one
|
||||
INSERT INTO
|
||||
users (
|
||||
|
||||
Reference in New Issue
Block a user