-
This commit is contained in:
@ -2,6 +2,7 @@ package interfaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/RyanCopley/skybridge/user/internal/domain"
|
||||
@ -35,6 +36,14 @@ type UserRepository interface {
|
||||
|
||||
// ExistsByEmail checks if a user exists with the given email
|
||||
ExistsByEmail(ctx context.Context, email string) (bool, error)
|
||||
|
||||
// Security methods
|
||||
IncrementFailedAttempts(ctx context.Context, userID uuid.UUID, lockoutDuration time.Duration) error
|
||||
ResetFailedAttempts(ctx context.Context, userID uuid.UUID) error
|
||||
GetFailedAttempts(ctx context.Context, userID uuid.UUID) (int, *time.Time, error)
|
||||
SetEmailVerified(ctx context.Context, userID uuid.UUID, verified bool) error
|
||||
UpdatePassword(ctx context.Context, userID uuid.UUID, passwordHash string) error
|
||||
UpdateTwoFactorSettings(ctx context.Context, userID uuid.UUID, enabled bool, secret *string, backupCodes []string) error
|
||||
}
|
||||
|
||||
// UserProfileRepository defines the interface for user profile operations
|
||||
@ -126,4 +135,39 @@ type GetEventsResponse struct {
|
||||
Limit int `json:"limit"`
|
||||
Offset int `json:"offset"`
|
||||
HasMore bool `json:"has_more"`
|
||||
}
|
||||
|
||||
// PasswordResetTokenRepository defines the interface for password reset token operations
|
||||
type PasswordResetTokenRepository interface {
|
||||
Create(ctx context.Context, token *domain.PasswordResetToken) error
|
||||
GetByToken(ctx context.Context, token string) (*domain.PasswordResetToken, error)
|
||||
MarkAsUsed(ctx context.Context, tokenID uuid.UUID) error
|
||||
DeleteExpired(ctx context.Context) error
|
||||
DeleteByUserID(ctx context.Context, userID uuid.UUID) error
|
||||
}
|
||||
|
||||
// EmailVerificationTokenRepository defines the interface for email verification token operations
|
||||
type EmailVerificationTokenRepository interface {
|
||||
Create(ctx context.Context, token *domain.EmailVerificationToken) error
|
||||
GetByToken(ctx context.Context, token string) (*domain.EmailVerificationToken, error)
|
||||
MarkAsUsed(ctx context.Context, tokenID uuid.UUID) error
|
||||
DeleteExpired(ctx context.Context) error
|
||||
DeleteByUserID(ctx context.Context, userID uuid.UUID) error
|
||||
}
|
||||
|
||||
// LoginAttemptRepository defines the interface for login attempt tracking
|
||||
type LoginAttemptRepository interface {
|
||||
Create(ctx context.Context, attempt *domain.LoginAttempt) error
|
||||
GetRecentAttempts(ctx context.Context, email string, since time.Time) ([]domain.LoginAttempt, error)
|
||||
GetFailedAttemptsCount(ctx context.Context, email string, since time.Time) (int, error)
|
||||
DeleteOldAttempts(ctx context.Context, before time.Time) error
|
||||
}
|
||||
|
||||
// TwoFactorRecoveryCodeRepository defines the interface for 2FA recovery code operations
|
||||
type TwoFactorRecoveryCodeRepository interface {
|
||||
Create(ctx context.Context, codes []domain.TwoFactorRecoveryCode) error
|
||||
GetByUserID(ctx context.Context, userID uuid.UUID) ([]domain.TwoFactorRecoveryCode, error)
|
||||
MarkAsUsed(ctx context.Context, codeID uuid.UUID) error
|
||||
DeleteByUserID(ctx context.Context, userID uuid.UUID) error
|
||||
ValidateCode(ctx context.Context, userID uuid.UUID, codeHash string) (bool, error)
|
||||
}
|
||||
Reference in New Issue
Block a user