mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
feat: backend support for creating and storing service accounts (#22698)
Add is_service_account column to users table with CHECK constraints enforcing login_type='none' and empty email for service accounts. Update user creation API to validate service account constraints. Related to: https://linear.app/codercom/issue/PLAT-27/feat-backend-support-for-creating-and-storing-service-accounts
This commit is contained in:
@@ -57,7 +57,7 @@ SELECT
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
(LOWER(username) = LOWER(@username) OR LOWER(email) = LOWER(@email)) AND
|
||||
(LOWER(username) = LOWER(@username) OR (@email != '' AND LOWER(email) = LOWER(@email))) AND
|
||||
deleted = false
|
||||
LIMIT
|
||||
1;
|
||||
@@ -92,13 +92,15 @@ INSERT INTO
|
||||
updated_at,
|
||||
rbac_roles,
|
||||
login_type,
|
||||
status
|
||||
status,
|
||||
is_service_account
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, $9,
|
||||
-- if the status passed in is empty, fallback to dormant, which is what
|
||||
-- we were doing before.
|
||||
COALESCE(NULLIF(@status::text, '')::user_status, 'dormant'::user_status)
|
||||
COALESCE(NULLIF(@status::text, '')::user_status, 'dormant'::user_status),
|
||||
@is_service_account::bool
|
||||
) RETURNING *;
|
||||
|
||||
-- name: UpdateUserProfile :one
|
||||
|
||||
Reference in New Issue
Block a user