mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: use unique ID for linked accounts (#3441)
- move OAuth-related fields off of api_keys into a new user_links table - restrict users to single form of login - process updates to user email/usernames for OIDC - added a login_type column to users
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
-- name: GetUserLinkByLinkedID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
user_links
|
||||
WHERE
|
||||
linked_id = $1;
|
||||
|
||||
-- name: GetUserLinkByUserIDLoginType :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
user_links
|
||||
WHERE
|
||||
user_id = $1 AND login_type = $2;
|
||||
|
||||
-- name: InsertUserLink :one
|
||||
INSERT INTO
|
||||
user_links (
|
||||
user_id,
|
||||
login_type,
|
||||
linked_id,
|
||||
oauth_access_token,
|
||||
oauth_refresh_token,
|
||||
oauth_expiry
|
||||
)
|
||||
VALUES
|
||||
( $1, $2, $3, $4, $5, $6 ) RETURNING *;
|
||||
|
||||
-- name: UpdateUserLinkedID :one
|
||||
UPDATE
|
||||
user_links
|
||||
SET
|
||||
linked_id = $1
|
||||
WHERE
|
||||
user_id = $2 AND login_type = $3 RETURNING *;
|
||||
|
||||
-- name: UpdateUserLink :one
|
||||
UPDATE
|
||||
user_links
|
||||
SET
|
||||
oauth_access_token = $1,
|
||||
oauth_refresh_token = $2,
|
||||
oauth_expiry = $3
|
||||
WHERE
|
||||
user_id = $4 AND login_type = $5 RETURNING *;
|
||||
Reference in New Issue
Block a user