Yimaru-BackEnd/internal/domain/otp.go

52 lines
924 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 Otp struct {
ID int64
UserName string
SentTo string
Medium OtpMedium
For OtpFor
Otp string
Used bool
UsedAt time.Time
CreatedAt time.Time
ExpiresAt time.Time
}
type VerifyOtpReq struct {
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Otp string `json:"otp" validate:"required"`
}
type ResendOtpReq struct {
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
}