889 lines
19 KiB
Go
889 lines
19 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: query.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const addSvg = `-- name: AddSvg :exec
|
|
INSERT INTO svg_icon (svg) VALUES (?)
|
|
`
|
|
|
|
func (q *Queries) AddSvg(ctx context.Context, svg string) error {
|
|
_, err := q.db.ExecContext(ctx, addSvg, svg)
|
|
return err
|
|
}
|
|
|
|
const addUserPermission = `-- name: AddUserPermission :exec
|
|
INSERT INTO user_permission (user_id, permission) VALUES (?, ?)
|
|
`
|
|
|
|
type AddUserPermissionParams struct {
|
|
UserID string
|
|
Permission string
|
|
}
|
|
|
|
func (q *Queries) AddUserPermission(ctx context.Context, arg AddUserPermissionParams) error {
|
|
_, err := q.db.ExecContext(ctx, addUserPermission, arg.UserID, arg.Permission)
|
|
return err
|
|
}
|
|
|
|
const approveClient = `-- name: ApproveClient :exec
|
|
INSERT INTO client_approvals (user_id, client_id)
|
|
VALUES (?, ?)
|
|
`
|
|
|
|
type ApproveClientParams struct {
|
|
UserID string
|
|
ClientID string
|
|
}
|
|
|
|
func (q *Queries) ApproveClient(ctx context.Context, arg ApproveClientParams) error {
|
|
_, err := q.db.ExecContext(ctx, approveClient, arg.UserID, arg.ClientID)
|
|
return err
|
|
}
|
|
|
|
const clientApproved = `-- name: ClientApproved :one
|
|
SELECT id, user_id, client_id
|
|
FROM client_approvals
|
|
WHERE user_id = ? AND client_id = ?
|
|
`
|
|
|
|
type ClientApprovedParams struct {
|
|
UserID string
|
|
ClientID string
|
|
}
|
|
|
|
func (q *Queries) ClientApproved(ctx context.Context, arg ClientApprovedParams) (ClientApproval, error) {
|
|
row := q.db.QueryRowContext(ctx, clientApproved, arg.UserID, arg.ClientID)
|
|
var i ClientApproval
|
|
err := row.Scan(&i.ID, &i.UserID, &i.ClientID)
|
|
return i, err
|
|
}
|
|
|
|
const createAuthorizationCode = `-- name: CreateAuthorizationCode :exec
|
|
INSERT INTO authorization_codes (code, code_challenge, code_challenge_method, user_id, client_id, scope, redirect_uri, expires_at)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
`
|
|
|
|
type CreateAuthorizationCodeParams struct {
|
|
Code string
|
|
CodeChallenge string
|
|
CodeChallengeMethod string
|
|
UserID string
|
|
ClientID string
|
|
Scope sql.NullString
|
|
RedirectUri string
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateAuthorizationCode(ctx context.Context, arg CreateAuthorizationCodeParams) error {
|
|
_, err := q.db.ExecContext(ctx, createAuthorizationCode,
|
|
arg.Code,
|
|
arg.CodeChallenge,
|
|
arg.CodeChallengeMethod,
|
|
arg.UserID,
|
|
arg.ClientID,
|
|
arg.Scope,
|
|
arg.RedirectUri,
|
|
arg.ExpiresAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const createCustomer = `-- name: CreateCustomer :exec
|
|
INSERT INTO customer (
|
|
id
|
|
,max_nkode_len
|
|
,min_nkode_len
|
|
,distinct_sets
|
|
,distinct_attributes
|
|
,lock_out
|
|
,expiration
|
|
,attribute_values
|
|
,set_values
|
|
,last_renew
|
|
,created_at
|
|
)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?)
|
|
`
|
|
|
|
type CreateCustomerParams struct {
|
|
ID string
|
|
MaxNkodeLen int64
|
|
MinNkodeLen int64
|
|
DistinctSets int64
|
|
DistinctAttributes int64
|
|
LockOut int64
|
|
Expiration int64
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
LastRenew string
|
|
CreatedAt string
|
|
}
|
|
|
|
func (q *Queries) CreateCustomer(ctx context.Context, arg CreateCustomerParams) error {
|
|
_, err := q.db.ExecContext(ctx, createCustomer,
|
|
arg.ID,
|
|
arg.MaxNkodeLen,
|
|
arg.MinNkodeLen,
|
|
arg.DistinctSets,
|
|
arg.DistinctAttributes,
|
|
arg.LockOut,
|
|
arg.Expiration,
|
|
arg.AttributeValues,
|
|
arg.SetValues,
|
|
arg.LastRenew,
|
|
arg.CreatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const createOIDCClient = `-- name: CreateOIDCClient :exec
|
|
INSERT INTO clients (id, name, owner)
|
|
VALUES (?, ?, ?)
|
|
`
|
|
|
|
type CreateOIDCClientParams struct {
|
|
ID string
|
|
Name string
|
|
Owner string
|
|
}
|
|
|
|
func (q *Queries) CreateOIDCClient(ctx context.Context, arg CreateOIDCClientParams) error {
|
|
_, err := q.db.ExecContext(ctx, createOIDCClient, arg.ID, arg.Name, arg.Owner)
|
|
return err
|
|
}
|
|
|
|
const createRedirectURI = `-- name: CreateRedirectURI :exec
|
|
INSERT INTO client_redirects (uri, client_id)
|
|
VALUES (?, ?)
|
|
`
|
|
|
|
type CreateRedirectURIParams struct {
|
|
Uri string
|
|
ClientID string
|
|
}
|
|
|
|
func (q *Queries) CreateRedirectURI(ctx context.Context, arg CreateRedirectURIParams) error {
|
|
_, err := q.db.ExecContext(ctx, createRedirectURI, arg.Uri, arg.ClientID)
|
|
return err
|
|
}
|
|
|
|
const createSession = `-- name: CreateSession :exec
|
|
INSERT INTO sessions (id, user_id, expires_at)
|
|
VALUES (?, ?, ?)
|
|
`
|
|
|
|
type CreateSessionParams struct {
|
|
ID string
|
|
UserID string
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) error {
|
|
_, err := q.db.ExecContext(ctx, createSession, arg.ID, arg.UserID, arg.ExpiresAt)
|
|
return err
|
|
}
|
|
|
|
const createToken = `-- name: CreateToken :exec
|
|
INSERT INTO tokens (token_type, token_value, user_id, client_id, scope, expires_at)
|
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
`
|
|
|
|
type CreateTokenParams struct {
|
|
TokenType string
|
|
TokenValue string
|
|
UserID string
|
|
ClientID string
|
|
Scope sql.NullString
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
func (q *Queries) CreateToken(ctx context.Context, arg CreateTokenParams) error {
|
|
_, err := q.db.ExecContext(ctx, createToken,
|
|
arg.TokenType,
|
|
arg.TokenValue,
|
|
arg.UserID,
|
|
arg.ClientID,
|
|
arg.Scope,
|
|
arg.ExpiresAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const createUser = `-- name: CreateUser :exec
|
|
INSERT INTO user (
|
|
id
|
|
,email
|
|
,renew
|
|
,refresh_token
|
|
,customer_id
|
|
,code
|
|
,mask
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
,alpha_key
|
|
,set_key
|
|
,pass_key
|
|
,mask_key
|
|
,salt
|
|
,max_nkode_len
|
|
,idx_interface
|
|
,svg_id_interface
|
|
,created_at
|
|
)
|
|
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID string
|
|
Email string
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
CustomerID string
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
CreatedAt sql.NullString
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, createUser,
|
|
arg.ID,
|
|
arg.Email,
|
|
arg.Renew,
|
|
arg.RefreshToken,
|
|
arg.CustomerID,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AttributesPerKey,
|
|
arg.NumberOfKeys,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.MaxNkodeLen,
|
|
arg.IdxInterface,
|
|
arg.SvgIDInterface,
|
|
arg.CreatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const deleteAuthCode = `-- name: DeleteAuthCode :exec
|
|
DELETE FROM authorization_codes
|
|
WHERE code = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteAuthCode(ctx context.Context, code string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteAuthCode, code)
|
|
return err
|
|
}
|
|
|
|
const deleteOldAuthCodes = `-- name: DeleteOldAuthCodes :exec
|
|
DELETE FROM authorization_codes
|
|
WHERE expires_at < CURRENT_TIMESTAMP
|
|
`
|
|
|
|
func (q *Queries) DeleteOldAuthCodes(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteOldAuthCodes)
|
|
return err
|
|
}
|
|
|
|
const deleteOldSessions = `-- name: DeleteOldSessions :exec
|
|
DELETE FROM sessions
|
|
WHERE expires_at < CURRENT_TIMESTAMP
|
|
`
|
|
|
|
func (q *Queries) DeleteOldSessions(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteOldSessions)
|
|
return err
|
|
}
|
|
|
|
const deleteOldTokens = `-- name: DeleteOldTokens :exec
|
|
DELETE FROM tokens
|
|
WHERE expires_at < CURRENT_TIMESTAMP
|
|
`
|
|
|
|
func (q *Queries) DeleteOldTokens(ctx context.Context) error {
|
|
_, err := q.db.ExecContext(ctx, deleteOldTokens)
|
|
return err
|
|
}
|
|
|
|
const deleteRedirectURI = `-- name: DeleteRedirectURI :exec
|
|
DELETE FROM client_redirects
|
|
WHERE uri = ? AND client_id = ?
|
|
`
|
|
|
|
type DeleteRedirectURIParams struct {
|
|
Uri string
|
|
ClientID string
|
|
}
|
|
|
|
func (q *Queries) DeleteRedirectURI(ctx context.Context, arg DeleteRedirectURIParams) error {
|
|
_, err := q.db.ExecContext(ctx, deleteRedirectURI, arg.Uri, arg.ClientID)
|
|
return err
|
|
}
|
|
|
|
const getAuthorizationCode = `-- name: GetAuthorizationCode :one
|
|
SELECT id, code, code_challenge, code_challenge_method, user_id, client_id, scope, redirect_uri, created_at, expires_at, used_at
|
|
FROM authorization_codes
|
|
WHERE code = ?
|
|
`
|
|
|
|
func (q *Queries) GetAuthorizationCode(ctx context.Context, code string) (AuthorizationCode, error) {
|
|
row := q.db.QueryRowContext(ctx, getAuthorizationCode, code)
|
|
var i AuthorizationCode
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Code,
|
|
&i.CodeChallenge,
|
|
&i.CodeChallengeMethod,
|
|
&i.UserID,
|
|
&i.ClientID,
|
|
&i.Scope,
|
|
&i.RedirectUri,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
&i.UsedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getClientRedirectURIs = `-- name: GetClientRedirectURIs :many
|
|
SELECT id, uri, client_id, created_at
|
|
FROM client_redirects
|
|
WHERE client_id = ?
|
|
`
|
|
|
|
func (q *Queries) GetClientRedirectURIs(ctx context.Context, clientID string) ([]ClientRedirect, error) {
|
|
rows, err := q.db.QueryContext(ctx, getClientRedirectURIs, clientID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ClientRedirect
|
|
for rows.Next() {
|
|
var i ClientRedirect
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Uri,
|
|
&i.ClientID,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getCustomer = `-- name: GetCustomer :one
|
|
SELECT
|
|
max_nkode_len
|
|
,min_nkode_len
|
|
,distinct_sets
|
|
,distinct_attributes
|
|
,lock_out
|
|
,expiration
|
|
,attribute_values
|
|
,set_values
|
|
FROM customer
|
|
WHERE id = ?
|
|
`
|
|
|
|
type GetCustomerRow struct {
|
|
MaxNkodeLen int64
|
|
MinNkodeLen int64
|
|
DistinctSets int64
|
|
DistinctAttributes int64
|
|
LockOut int64
|
|
Expiration int64
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
}
|
|
|
|
func (q *Queries) GetCustomer(ctx context.Context, id string) (GetCustomerRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getCustomer, id)
|
|
var i GetCustomerRow
|
|
err := row.Scan(
|
|
&i.MaxNkodeLen,
|
|
&i.MinNkodeLen,
|
|
&i.DistinctSets,
|
|
&i.DistinctAttributes,
|
|
&i.LockOut,
|
|
&i.Expiration,
|
|
&i.AttributeValues,
|
|
&i.SetValues,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getOIDCClientByID = `-- name: GetOIDCClientByID :one
|
|
SELECT id, name, owner, created_at
|
|
FROM clients
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetOIDCClientByID(ctx context.Context, id string) (Client, error) {
|
|
row := q.db.QueryRowContext(ctx, getOIDCClientByID, id)
|
|
var i Client
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Owner,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSessionByID = `-- name: GetSessionByID :one
|
|
SELECT id, user_id, created_at, expires_at
|
|
FROM sessions
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetSessionByID(ctx context.Context, id string) (Session, error) {
|
|
row := q.db.QueryRowContext(ctx, getSessionByID, id)
|
|
var i Session
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getSvgCount = `-- name: GetSvgCount :one
|
|
SELECT COUNT(*) as count FROM svg_icon
|
|
`
|
|
|
|
func (q *Queries) GetSvgCount(ctx context.Context) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, getSvgCount)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const getSvgID = `-- name: GetSvgID :one
|
|
SELECT svg
|
|
FROM svg_icon
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) GetSvgID(ctx context.Context, id int64) (string, error) {
|
|
row := q.db.QueryRowContext(ctx, getSvgID, id)
|
|
var svg string
|
|
err := row.Scan(&svg)
|
|
return svg, err
|
|
}
|
|
|
|
const getTokenByValue = `-- name: GetTokenByValue :one
|
|
SELECT id, token_type, token_value, user_id, client_id, scope, created_at, expires_at
|
|
FROM tokens
|
|
WHERE token_value = ?
|
|
`
|
|
|
|
func (q *Queries) GetTokenByValue(ctx context.Context, tokenValue string) (Token, error) {
|
|
row := q.db.QueryRowContext(ctx, getTokenByValue, tokenValue)
|
|
var i Token
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TokenType,
|
|
&i.TokenValue,
|
|
&i.UserID,
|
|
&i.ClientID,
|
|
&i.Scope,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUser = `-- name: GetUser :one
|
|
SELECT
|
|
id
|
|
,renew
|
|
,refresh_token
|
|
,code
|
|
,mask
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
,alpha_key
|
|
,set_key
|
|
,pass_key
|
|
,mask_key
|
|
,salt
|
|
,max_nkode_len
|
|
,idx_interface
|
|
,svg_id_interface
|
|
FROM user
|
|
WHERE user.email = ? AND user.customer_id = ?
|
|
`
|
|
|
|
type GetUserParams struct {
|
|
Email string
|
|
CustomerID string
|
|
}
|
|
|
|
type GetUserRow struct {
|
|
ID string
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
}
|
|
|
|
func (q *Queries) GetUser(ctx context.Context, arg GetUserParams) (GetUserRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getUser, arg.Email, arg.CustomerID)
|
|
var i GetUserRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Renew,
|
|
&i.RefreshToken,
|
|
&i.Code,
|
|
&i.Mask,
|
|
&i.AttributesPerKey,
|
|
&i.NumberOfKeys,
|
|
&i.AlphaKey,
|
|
&i.SetKey,
|
|
&i.PassKey,
|
|
&i.MaskKey,
|
|
&i.Salt,
|
|
&i.MaxNkodeLen,
|
|
&i.IdxInterface,
|
|
&i.SvgIDInterface,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserClients = `-- name: GetUserClients :many
|
|
|
|
SELECT id, name, owner, created_at
|
|
FROM clients
|
|
WHERE owner = ?
|
|
`
|
|
|
|
// -------- go-oidc ----------
|
|
func (q *Queries) GetUserClients(ctx context.Context, owner string) ([]Client, error) {
|
|
rows, err := q.db.QueryContext(ctx, getUserClients, owner)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Client
|
|
for rows.Next() {
|
|
var i Client
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Owner,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getUserPermissions = `-- name: GetUserPermissions :many
|
|
SELECT permission FROM user_permission WHERE user_id = ?
|
|
`
|
|
|
|
func (q *Queries) GetUserPermissions(ctx context.Context, userID string) ([]string, error) {
|
|
rows, err := q.db.QueryContext(ctx, getUserPermissions, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []string
|
|
for rows.Next() {
|
|
var permission string
|
|
if err := rows.Scan(&permission); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, permission)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const getUserRenew = `-- name: GetUserRenew :many
|
|
SELECT
|
|
id
|
|
,alpha_key
|
|
,set_key
|
|
,attributes_per_key
|
|
,number_of_keys
|
|
FROM user
|
|
WHERE customer_id = ?
|
|
`
|
|
|
|
type GetUserRenewRow struct {
|
|
ID string
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
}
|
|
|
|
func (q *Queries) GetUserRenew(ctx context.Context, customerID string) ([]GetUserRenewRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, getUserRenew, customerID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetUserRenewRow
|
|
for rows.Next() {
|
|
var i GetUserRenewRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.AlphaKey,
|
|
&i.SetKey,
|
|
&i.AttributesPerKey,
|
|
&i.NumberOfKeys,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const refreshUserPasscode = `-- name: RefreshUserPasscode :exec
|
|
UPDATE user
|
|
SET
|
|
renew = ?
|
|
,code = ?
|
|
,mask = ?
|
|
,alpha_key = ?
|
|
,set_key = ?
|
|
,pass_key = ?
|
|
,mask_key = ?
|
|
,salt = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RefreshUserPasscodeParams struct {
|
|
Renew int64
|
|
Code string
|
|
Mask string
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RefreshUserPasscode(ctx context.Context, arg RefreshUserPasscodeParams) error {
|
|
_, err := q.db.ExecContext(ctx, refreshUserPasscode,
|
|
arg.Renew,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const renewCustomer = `-- name: RenewCustomer :exec
|
|
UPDATE customer
|
|
SET attribute_values = ?, set_values = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RenewCustomerParams struct {
|
|
AttributeValues []byte
|
|
SetValues []byte
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RenewCustomer(ctx context.Context, arg RenewCustomerParams) error {
|
|
_, err := q.db.ExecContext(ctx, renewCustomer, arg.AttributeValues, arg.SetValues, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const renewUser = `-- name: RenewUser :exec
|
|
UPDATE user
|
|
SET alpha_key = ?, set_key = ?, renew = ?
|
|
WHERE id = ?
|
|
`
|
|
|
|
type RenewUserParams struct {
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
Renew int64
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) RenewUser(ctx context.Context, arg RenewUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, renewUser,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.Renew,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const revokeClientApproval = `-- name: RevokeClientApproval :exec
|
|
DELETE FROM client_approvals
|
|
WHERE user_id = ? AND client_id = ?
|
|
`
|
|
|
|
type RevokeClientApprovalParams struct {
|
|
UserID string
|
|
ClientID string
|
|
}
|
|
|
|
func (q *Queries) RevokeClientApproval(ctx context.Context, arg RevokeClientApprovalParams) error {
|
|
_, err := q.db.ExecContext(ctx, revokeClientApproval, arg.UserID, arg.ClientID)
|
|
return err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :exec
|
|
UPDATE user
|
|
SET renew = ?
|
|
,refresh_token = ?
|
|
,code = ?
|
|
,mask = ?
|
|
,attributes_per_key = ?
|
|
,number_of_keys = ?
|
|
,alpha_key = ?
|
|
,set_key = ?
|
|
,pass_key = ?
|
|
,mask_key = ?
|
|
,salt = ?
|
|
,max_nkode_len = ?
|
|
,idx_interface = ?
|
|
,svg_id_interface = ?
|
|
WHERE email = ? AND customer_id = ?
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
Renew int64
|
|
RefreshToken sql.NullString
|
|
Code string
|
|
Mask string
|
|
AttributesPerKey int64
|
|
NumberOfKeys int64
|
|
AlphaKey []byte
|
|
SetKey []byte
|
|
PassKey []byte
|
|
MaskKey []byte
|
|
Salt []byte
|
|
MaxNkodeLen int64
|
|
IdxInterface []byte
|
|
SvgIDInterface []byte
|
|
Email string
|
|
CustomerID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUser,
|
|
arg.Renew,
|
|
arg.RefreshToken,
|
|
arg.Code,
|
|
arg.Mask,
|
|
arg.AttributesPerKey,
|
|
arg.NumberOfKeys,
|
|
arg.AlphaKey,
|
|
arg.SetKey,
|
|
arg.PassKey,
|
|
arg.MaskKey,
|
|
arg.Salt,
|
|
arg.MaxNkodeLen,
|
|
arg.IdxInterface,
|
|
arg.SvgIDInterface,
|
|
arg.Email,
|
|
arg.CustomerID,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const updateUserInterface = `-- name: UpdateUserInterface :exec
|
|
UPDATE user SET idx_interface = ?, last_login = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateUserInterfaceParams struct {
|
|
IdxInterface []byte
|
|
LastLogin interface{}
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUserInterface(ctx context.Context, arg UpdateUserInterfaceParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUserInterface, arg.IdxInterface, arg.LastLogin, arg.ID)
|
|
return err
|
|
}
|
|
|
|
const updateUserRefreshToken = `-- name: UpdateUserRefreshToken :exec
|
|
UPDATE user SET refresh_token = ? WHERE id = ?
|
|
`
|
|
|
|
type UpdateUserRefreshTokenParams struct {
|
|
RefreshToken sql.NullString
|
|
ID string
|
|
}
|
|
|
|
func (q *Queries) UpdateUserRefreshToken(ctx context.Context, arg UpdateUserRefreshTokenParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateUserRefreshToken, arg.RefreshToken, arg.ID)
|
|
return err
|
|
}
|