25 lines
860 B
Go
25 lines
860 B
Go
package port
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.threesix.ai/jordan/persona-community-1/services/persona-api/internal/domain"
|
|
)
|
|
|
|
// AuthCodeRepository defines the interface for auth code persistence.
|
|
type AuthCodeRepository interface {
|
|
// Create persists a new auth code.
|
|
Create(ctx context.Context, code *domain.AuthCode) error
|
|
|
|
// FindValid returns an unused, non-expired code matching the criteria.
|
|
// Returns domain.ErrInvalidAuthCode if no valid code exists.
|
|
FindValid(ctx context.Context, email string, code string, purpose domain.AuthCodePurpose) (*domain.AuthCode, error)
|
|
|
|
// MarkUsed sets the used_at timestamp on a code, making it single-use.
|
|
MarkUsed(ctx context.Context, id string) error
|
|
|
|
// DeleteExpired removes codes that have passed their expiry time.
|
|
// Returns the number of codes deleted.
|
|
DeleteExpired(ctx context.Context) (int, error)
|
|
}
|