Files
uptimesebi/internal/store/copyfrom.go
T
Sebastian UnterschützandClaude Opus 5.5 dbea42e7a5 feat(auth): add single-use totp recovery codes
Codes are stored as SHA-256 hashes and consumed with one conditional
update, so concurrent use of the same code succeeds at most once.

Refs #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 00:35:20 +01:00

44 lines
1009 B
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: copyfrom.go
package store
import (
"context"
)
// iteratorForInsertRecoveryCodes implements pgx.CopyFromSource.
type iteratorForInsertRecoveryCodes struct {
rows []InsertRecoveryCodesParams
skippedFirstNextCall bool
}
func (r *iteratorForInsertRecoveryCodes) Next() bool {
if len(r.rows) == 0 {
return false
}
if !r.skippedFirstNextCall {
r.skippedFirstNextCall = true
return true
}
r.rows = r.rows[1:]
return len(r.rows) > 0
}
func (r iteratorForInsertRecoveryCodes) Values() ([]interface{}, error) {
return []interface{}{
r.rows[0].UserID,
r.rows[0].CodeHash,
}, nil
}
func (r iteratorForInsertRecoveryCodes) Err() error {
return nil
}
func (q *Queries) InsertRecoveryCodes(ctx context.Context, arg []InsertRecoveryCodesParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"recovery_codes"}, []string{"user_id", "code_hash"}, &iteratorForInsertRecoveryCodes{rows: arg})
}