implemented verifiaction db

This commit is contained in:
Stephan D
2026-02-05 20:51:03 +01:00
parent 4639b2c610
commit f8a3bef2e6
12 changed files with 290 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
package verification
import (
"context"
"errors"
"time"
"github.com/tech/sendico/pkg/model"
"go.mongodb.org/mongo-driver/v2/bson"
)
var (
ErrTokenNotFound = errors.New("verification token not found")
ErrTokenAlreadyUsed = errors.New("verification token already used")
ErrTokenExpired = errors.New("verification token expired")
)
type DB interface {
// template.DB[*model.VerificationToken]
Create(
ctx context.Context,
accountRef bson.ObjectID,
purpose model.VerificationPurpose,
target string,
ttl time.Duration,
) (rawToken string, err error)
Consume(ctx context.Context, rawToken string) (*model.VerificationToken, error)
}