mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat: Add user roles, but do not yet enforce them (#1200)
* chore: Rework roles to be expandable by name alone
This commit is contained in:
@ -21,6 +21,15 @@ INSERT INTO
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5) RETURNING *;
|
||||
|
||||
|
||||
-- name: GetOrganizationMembershipsByUserID :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
organization_members
|
||||
WHERE
|
||||
user_id = $1;
|
||||
|
||||
-- name: GetOrganizationIDsByMemberIDs :many
|
||||
SELECT
|
||||
user_id, array_agg(organization_id) :: uuid [ ] AS "organization_IDs"
|
||||
@ -30,3 +39,14 @@ WHERE
|
||||
user_id = ANY(@ids :: uuid [ ])
|
||||
GROUP BY
|
||||
user_id;
|
||||
|
||||
-- name: UpdateMemberRoles :one
|
||||
UPDATE
|
||||
organization_members
|
||||
SET
|
||||
-- Remove all duplicates from the roles.
|
||||
roles = ARRAY(SELECT DISTINCT UNNEST(@granted_roles :: text[]))
|
||||
WHERE
|
||||
user_id = @user_id
|
||||
AND organization_id = @org_id
|
||||
RETURNING *;
|
Reference in New Issue
Block a user