Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrVerificationNotFound = errors.New("verification not found")
)
Error types for verification operations
Functions ¶
func ValidateCreateVerificationRequest ¶
func ValidateCreateVerificationRequest(req *CreateVerificationRequest) error
ValidateCreateVerificationRequest validates a create verification request
Types ¶
type CreateVerificationRequest ¶
type CreateVerificationRequest struct {
UserID string `json:"user_id"`
Identifier string `json:"identifier"`
Token string `json:"token"`
Type VerificationType `json:"type"`
ExpiresAt time.Time `json:"expires_at"`
}
CreateVerificationRequest represents a request to create a verification token
type Repository ¶
type Repository interface {
// Create creates a new verification token
Create(verification *Verification) error
// FindByToken retrieves a verification by token
FindByToken(token string) (*Verification, error)
// FindByHashedToken retrieves a verification by matching a plain token against a hashed token
// It takes a plain token and finds the verification where the hashed token matches
FindByHashedToken(plainToken string) (*Verification, error)
// FindByIdentifierAndType retrieves a verification by identifier and type
FindByIdentifierAndType(identifier string, verType VerificationType) (*Verification, error)
// Delete deletes a verification by ID
Delete(id string) error
// DeleteByToken deletes a verification by token
DeleteByToken(token string) error
// DeleteExpired deletes all expired verifications
DeleteExpired() error
// Count returns the total number of verifications
Count() (int, error)
// ExistsByToken checks if a verification exists by token
ExistsByToken(token string) (bool, error)
// ExistsByIdentifierAndType checks if a verification exists by identifier and type
ExistsByIdentifierAndType(identifier string, verType VerificationType) (bool, error)
}
Repository defines the interface for verification data access
type Verification ¶
type Verification struct {
ID string `json:"id"`
UserID string `json:"user_id,omitempty"` // User ID (optional, used for email change)
Identifier string `json:"identifier"` // Email or other identifier
Token string `json:"token"`
Type VerificationType `json:"type"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Verification represents a verification token (email verification, password reset, etc.)
func (*Verification) IsExpired ¶
func (v *Verification) IsExpired() bool
IsExpired checks if the verification has expired
type VerificationType ¶
type VerificationType string
VerificationType defines the type of verification
const ( TypeEmailVerification VerificationType = "email_verification" TypePasswordReset VerificationType = "password_reset" TypeEmailChange VerificationType = "email_change" )
Click to show internal directories.
Click to hide internal directories.