Yimaru-BackEnd/internal/domain/otp.go

47 lines
753 B
Go

package domain
import (
"errors"
"time"
)
var (
ErrOtpNotFound = errors.New("otp not found")
ErrOtpAlreadyUsed = errors.New("otp already used")
ErrInvalidOtp = errors.New("invalid otp")
ErrOtpExpired = errors.New("otp expired")
)
type OtpFor string
const (
OtpReset OtpFor = "reset"
OtpRegister OtpFor = "register"
)
type OtpMedium string
const (
OtpMediumEmail OtpMedium = "email"
OtpMediumSms OtpMedium = "sms"
)
type OtpProvider string
const (
TwilioSms OtpProvider = "twilio"
AfroMessage OtpProvider = "afro_message"
)
type Otp struct {
ID int64
SentTo string
Medium OtpMedium
For OtpFor
Otp string
Used bool
UsedAt time.Time
CreatedAt time.Time
ExpiresAt time.Time
}