Learners get email/SMS OTP codes via /user/sendResetCode; team members get reset links via new /team/sendResetCode and /team/resetPassword APIs, with admin panel integration docs. Co-authored-by: Cursor <cursoragent@cursor.com>
101 lines
2.4 KiB
Go
101 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: team_otps.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const CreateTeamOtp = `-- name: CreateTeamOtp :exec
|
|
INSERT INTO team_otps (
|
|
team_member_id,
|
|
sent_to,
|
|
medium,
|
|
otp_for,
|
|
otp,
|
|
expires_at
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
`
|
|
|
|
type CreateTeamOtpParams struct {
|
|
TeamMemberID int64 `json:"team_member_id"`
|
|
SentTo string `json:"sent_to"`
|
|
Medium string `json:"medium"`
|
|
OtpFor string `json:"otp_for"`
|
|
Otp string `json:"otp"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateTeamOtp(ctx context.Context, arg CreateTeamOtpParams) error {
|
|
_, err := q.db.Exec(ctx, CreateTeamOtp,
|
|
arg.TeamMemberID,
|
|
arg.SentTo,
|
|
arg.Medium,
|
|
arg.OtpFor,
|
|
arg.Otp,
|
|
arg.ExpiresAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const GetLatestTeamOtp = `-- name: GetLatestTeamOtp :one
|
|
SELECT id, team_member_id, sent_to, medium, otp_for, otp, used, used_at, created_at, expires_at
|
|
FROM team_otps
|
|
WHERE team_member_id = $1
|
|
ORDER BY id DESC
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetLatestTeamOtpRow struct {
|
|
ID int64 `json:"id"`
|
|
TeamMemberID int64 `json:"team_member_id"`
|
|
SentTo string `json:"sent_to"`
|
|
Medium string `json:"medium"`
|
|
OtpFor string `json:"otp_for"`
|
|
Otp string `json:"otp"`
|
|
Used bool `json:"used"`
|
|
UsedAt pgtype.Timestamptz `json:"used_at"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
ExpiresAt pgtype.Timestamptz `json:"expires_at"`
|
|
}
|
|
|
|
func (q *Queries) GetLatestTeamOtp(ctx context.Context, teamMemberID int64) (GetLatestTeamOtpRow, error) {
|
|
row := q.db.QueryRow(ctx, GetLatestTeamOtp, teamMemberID)
|
|
var i GetLatestTeamOtpRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.TeamMemberID,
|
|
&i.SentTo,
|
|
&i.Medium,
|
|
&i.OtpFor,
|
|
&i.Otp,
|
|
&i.Used,
|
|
&i.UsedAt,
|
|
&i.CreatedAt,
|
|
&i.ExpiresAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const MarkTeamOtpAsUsed = `-- name: MarkTeamOtpAsUsed :exec
|
|
UPDATE team_otps
|
|
SET used = TRUE, used_at = $2
|
|
WHERE id = $1
|
|
`
|
|
|
|
type MarkTeamOtpAsUsedParams struct {
|
|
ID int64 `json:"id"`
|
|
UsedAt pgtype.Timestamptz `json:"used_at"`
|
|
}
|
|
|
|
func (q *Queries) MarkTeamOtpAsUsed(ctx context.Context, arg MarkTeamOtpAsUsedParams) error {
|
|
_, err := q.db.Exec(ctx, MarkTeamOtpAsUsed, arg.ID, arg.UsedAt)
|
|
return err
|
|
}
|