mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Add profile pictures to OAuth users (#3855)
This supports GitHub and OIDC login for profile pictures!
This commit is contained in:
@ -2870,7 +2870,7 @@ func (q *sqlQuerier) GetAuthorizationUserRoles(ctx context.Context, userID uuid.
|
||||
|
||||
const getUserByEmailOrUsername = `-- name: GetUserByEmailOrUsername :one
|
||||
SELECT
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
@ -2898,13 +2898,14 @@ func (q *sqlQuerier) GetUserByEmailOrUsername(ctx context.Context, arg GetUserBy
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByID = `-- name: GetUserByID :one
|
||||
SELECT
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
@ -2926,6 +2927,7 @@ func (q *sqlQuerier) GetUserByID(ctx context.Context, id uuid.UUID) (User, error
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -2946,7 +2948,7 @@ func (q *sqlQuerier) GetUserCount(ctx context.Context) (int64, error) {
|
||||
|
||||
const getUsers = `-- name: GetUsers :many
|
||||
SELECT
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
FROM
|
||||
users
|
||||
WHERE
|
||||
@ -3039,6 +3041,7 @@ func (q *sqlQuerier) GetUsers(ctx context.Context, arg GetUsersParams) ([]User,
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -3054,7 +3057,7 @@ func (q *sqlQuerier) GetUsers(ctx context.Context, arg GetUsersParams) ([]User,
|
||||
}
|
||||
|
||||
const getUsersByIDs = `-- name: GetUsersByIDs :many
|
||||
SELECT id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type FROM users WHERE id = ANY($1 :: uuid [ ])
|
||||
SELECT id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url FROM users WHERE id = ANY($1 :: uuid [ ])
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetUsersByIDs(ctx context.Context, ids []uuid.UUID) ([]User, error) {
|
||||
@ -3076,6 +3079,7 @@ func (q *sqlQuerier) GetUsersByIDs(ctx context.Context, ids []uuid.UUID) ([]User
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -3103,7 +3107,7 @@ INSERT INTO
|
||||
login_type
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
`
|
||||
|
||||
type InsertUserParams struct {
|
||||
@ -3139,6 +3143,7 @@ func (q *sqlQuerier) InsertUser(ctx context.Context, arg InsertUserParams) (User
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -3168,16 +3173,18 @@ UPDATE
|
||||
SET
|
||||
email = $2,
|
||||
username = $3,
|
||||
updated_at = $4
|
||||
avatar_url = $4,
|
||||
updated_at = $5
|
||||
WHERE
|
||||
id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
`
|
||||
|
||||
type UpdateUserProfileParams struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
Email string `db:"email" json:"email"`
|
||||
Username string `db:"username" json:"username"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
Email string `db:"email" json:"email"`
|
||||
Username string `db:"username" json:"username"`
|
||||
AvatarURL sql.NullString `db:"avatar_url" json:"avatar_url"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfileParams) (User, error) {
|
||||
@ -3185,6 +3192,7 @@ func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfil
|
||||
arg.ID,
|
||||
arg.Email,
|
||||
arg.Username,
|
||||
arg.AvatarURL,
|
||||
arg.UpdatedAt,
|
||||
)
|
||||
var i User
|
||||
@ -3198,6 +3206,7 @@ func (q *sqlQuerier) UpdateUserProfile(ctx context.Context, arg UpdateUserProfil
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -3210,7 +3219,7 @@ SET
|
||||
rbac_roles = ARRAY(SELECT DISTINCT UNNEST($1 :: text[]))
|
||||
WHERE
|
||||
id = $2
|
||||
RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
`
|
||||
|
||||
type UpdateUserRolesParams struct {
|
||||
@ -3231,6 +3240,7 @@ func (q *sqlQuerier) UpdateUserRoles(ctx context.Context, arg UpdateUserRolesPar
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -3242,7 +3252,7 @@ SET
|
||||
status = $2,
|
||||
updated_at = $3
|
||||
WHERE
|
||||
id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type
|
||||
id = $1 RETURNING id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, login_type, avatar_url
|
||||
`
|
||||
|
||||
type UpdateUserStatusParams struct {
|
||||
@ -3264,6 +3274,7 @@ func (q *sqlQuerier) UpdateUserStatus(ctx context.Context, arg UpdateUserStatusP
|
||||
&i.Status,
|
||||
pq.Array(&i.RBACRoles),
|
||||
&i.LoginType,
|
||||
&i.AvatarURL,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user