feat: kavenegar sdk, otp generation and verifying
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
type OTPRepo interface {
|
||||
Create(ctx context.Context, phone string, otp *OTP) error
|
||||
Get(ctx context.Context, phone string) (*OTP, error)
|
||||
Delete(ctx context.Context, phone string) error
|
||||
}
|
||||
|
||||
@@ -17,7 +18,7 @@ type OTP struct {
|
||||
ID uuid.UUID
|
||||
Code string
|
||||
Phone string
|
||||
ExpiredAt time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
func NewOTP(phone string) *OTP {
|
||||
@@ -27,3 +28,7 @@ func NewOTP(phone string) *OTP {
|
||||
Phone: phone,
|
||||
}
|
||||
}
|
||||
|
||||
func (o *OTP) IsExpired() bool {
|
||||
return time.Now().After(o.ExpiresAt)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user