Files
mtusi2026lab7/backend/internal/adapter/repository/postgres/queries/security.sql.go
T

43 lines
1.2 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: security.sql
package queries
import (
"context"
"github.com/google/uuid"
)
const allowLogin = `-- name: AllowLogin :one
UPDATE login_limits SET attempts=CASE WHEN started_at<=clock_timestamp()-interval '60 seconds' THEN 1 ELSE attempts+1 END,
started_at=CASE WHEN started_at<=clock_timestamp()-interval '60 seconds' THEN clock_timestamp() ELSE started_at END
WHERE bucket=$1 AND (started_at<=clock_timestamp()-interval '60 seconds' OR attempts<10) RETURNING bucket
`
func (q *Queries) AllowLogin(ctx context.Context, bucket int16) (int16, error) {
row := q.db.QueryRow(ctx, allowLogin, bucket)
var bucket_2 int16
err := row.Scan(&bucket_2)
return bucket_2, err
}
const rehashPassword = `-- name: RehashPassword :one
UPDATE users SET password_hash=$1 WHERE id=$2 AND password_hash=$3 RETURNING id
`
type RehashPasswordParams struct {
Replacement string
UserID uuid.UUID
Previous string
}
func (q *Queries) RehashPassword(ctx context.Context, arg RehashPasswordParams) (uuid.UUID, error) {
row := q.db.QueryRow(ctx, rehashPassword, arg.Replacement, arg.UserID, arg.Previous)
var id uuid.UUID
err := row.Scan(&id)
return id, err
}