added admin options

This commit is contained in:
tumillanino
2025-10-28 14:19:54 +11:00
parent e88d625130
commit 788b46a5ea
10 changed files with 162 additions and 20 deletions

View File

@@ -13,7 +13,7 @@ import (
const createUser = `-- name: CreateUser :one
INSERT INTO users (email, ory_identity_id)
VALUES ($1, $2)
RETURNING id, email, created_at, ory_identity_id
RETURNING id, email, created_at, ory_identity_id, is_admin
`
type CreateUserParams struct {
@@ -29,12 +29,13 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e
&i.Email,
&i.CreatedAt,
&i.OryIdentityID,
&i.IsAdmin,
)
return i, err
}
const getUserByEmail = `-- name: GetUserByEmail :one
SELECT id, email, created_at, ory_identity_id FROM users WHERE email = $1 LIMIT 1
SELECT id, email, created_at, ory_identity_id, is_admin FROM users WHERE email = $1 LIMIT 1
`
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) {
@@ -45,12 +46,13 @@ func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error
&i.Email,
&i.CreatedAt,
&i.OryIdentityID,
&i.IsAdmin,
)
return i, err
}
const getUserByOryID = `-- name: GetUserByOryID :one
SELECT id, email, created_at, ory_identity_id FROM users WHERE ory_identity_id = $1 LIMIT 1
SELECT id, email, created_at, ory_identity_id, is_admin FROM users WHERE ory_identity_id = $1 LIMIT 1
`
func (q *Queries) GetUserByOryID(ctx context.Context, oryIdentityID sql.NullString) (User, error) {
@@ -61,6 +63,7 @@ func (q *Queries) GetUserByOryID(ctx context.Context, oryIdentityID sql.NullStri
&i.Email,
&i.CreatedAt,
&i.OryIdentityID,
&i.IsAdmin,
)
return i, err
}
@@ -69,7 +72,7 @@ const updateUserOryID = `-- name: UpdateUserOryID :one
UPDATE users
SET ory_identity_id = $1
WHERE email = $2
RETURNING id, email, created_at, ory_identity_id
RETURNING id, email, created_at, ory_identity_id, is_admin
`
type UpdateUserOryIDParams struct {
@@ -85,6 +88,7 @@ func (q *Queries) UpdateUserOryID(ctx context.Context, arg UpdateUserOryIDParams
&i.Email,
&i.CreatedAt,
&i.OryIdentityID,
&i.IsAdmin,
)
return i, err
}