feat: kavenegar sdk, otp generation and verifying

This commit is contained in:
2025-09-15 16:36:52 +03:30
parent 36cda3fd5a
commit 5829b471d5
9 changed files with 131 additions and 10 deletions
+6 -1
View File
@@ -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)
}