50 lines
879 B
Go
50 lines
879 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 {
|
|
UserName string `json:"user_name" validate:"required"`
|
|
Otp string `json:"otp" validate:"required"`
|
|
}
|
|
|
|
type ResendOtpReq struct {
|
|
UserName string `json:"user_name" validate:"required"`
|
|
}
|