94 lines
2 KiB
Go
94 lines
2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// source: reset.sql
|
|
|
|
package database
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const createReset = `-- name: CreateReset :one
|
|
INSERT INTO "password_reset" (
|
|
"identity_id",
|
|
"selector",
|
|
"verifier",
|
|
"valid_until"
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4
|
|
) RETURNING identity_id, selector, verifier, valid_until
|
|
`
|
|
|
|
type CreateResetParams struct {
|
|
IdentityID int64 `json:"identity_id"`
|
|
Selector string `json:"selector"`
|
|
Verifier []byte `json:"verifier"`
|
|
ValidUntil time.Time `json:"valid_until"`
|
|
}
|
|
|
|
func (q *Queries) CreateReset(ctx context.Context, arg CreateResetParams) (PasswordReset, error) {
|
|
row := q.db.QueryRowContext(ctx, createReset,
|
|
arg.IdentityID,
|
|
arg.Selector,
|
|
arg.Verifier,
|
|
arg.ValidUntil,
|
|
)
|
|
var i PasswordReset
|
|
err := row.Scan(
|
|
&i.IdentityID,
|
|
&i.Selector,
|
|
&i.Verifier,
|
|
&i.ValidUntil,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const destroyReset = `-- name: DestroyReset :exec
|
|
DELETE FROM "password_reset" WHERE "selector" = $1
|
|
`
|
|
|
|
func (q *Queries) DestroyReset(ctx context.Context, selector string) error {
|
|
_, err := q.db.ExecContext(ctx, destroyReset, selector)
|
|
return err
|
|
}
|
|
|
|
const getResetByIdentityID = `-- name: GetResetByIdentityID :one
|
|
SELECT
|
|
identity_id, selector, verifier, valid_until
|
|
FROM "password_reset"
|
|
WHERE "identity_id" = $1
|
|
`
|
|
|
|
func (q *Queries) GetResetByIdentityID(ctx context.Context, identityID int64) (PasswordReset, error) {
|
|
row := q.db.QueryRowContext(ctx, getResetByIdentityID, identityID)
|
|
var i PasswordReset
|
|
err := row.Scan(
|
|
&i.IdentityID,
|
|
&i.Selector,
|
|
&i.Verifier,
|
|
&i.ValidUntil,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getResetBySelector = `-- name: GetResetBySelector :one
|
|
SELECT
|
|
identity_id, selector, verifier, valid_until
|
|
FROM "password_reset"
|
|
WHERE "selector" = $1
|
|
`
|
|
|
|
func (q *Queries) GetResetBySelector(ctx context.Context, selector string) (PasswordReset, error) {
|
|
row := q.db.QueryRowContext(ctx, getResetBySelector, selector)
|
|
var i PasswordReset
|
|
err := row.Scan(
|
|
&i.IdentityID,
|
|
&i.Selector,
|
|
&i.Verifier,
|
|
&i.ValidUntil,
|
|
)
|
|
return i, err
|
|
}
|