diff --git a/pkg/service/delivery/validate_2fa.go b/pkg/service/delivery/2fa.go similarity index 83% rename from pkg/service/delivery/validate_2fa.go rename to pkg/service/delivery/2fa.go index 3682432..b8a9ff0 100644 --- a/pkg/service/delivery/validate_2fa.go +++ b/pkg/service/delivery/2fa.go @@ -5,7 +5,6 @@ import ( "Go_Food_Delivery/pkg/database/models/delivery" "context" "errors" - "fmt" "github.com/golang-jwt/jwt/v5" "github.com/pquerna/otp/totp" "log/slog" @@ -13,6 +12,17 @@ import ( "time" ) +func (deliverSrv *DeliveryService) GenerateTOTP(_ context.Context, phone string) (string, string, error) { + key, err := totp.Generate(totp.GenerateOpts{ + Issuer: "Food Delivery", + AccountName: phone, + }) + if err != nil { + return "", "", errors.New("error generating key") + } + return key.Secret(), key.URL(), nil +} + func (deliverSrv *DeliveryService) ValidateAccountDetails(ctx context.Context, phone string) (*delivery.DeliveryPerson, error) { var deliveryAccountInfo delivery.DeliveryPerson err := deliverSrv.db.Select(ctx, &deliveryAccountInfo, "phone", phone) @@ -22,7 +32,6 @@ func (deliverSrv *DeliveryService) ValidateAccountDetails(ctx context.Context, p if deliveryAccountInfo.Status != "AVAILABLE" { return nil, errors.New("account is inactive or not available") } - fmt.Printf("%+v", deliveryAccountInfo) return &deliveryAccountInfo, nil } diff --git a/pkg/service/delivery/generate_2fa.go b/pkg/service/delivery/generate_2fa.go deleted file mode 100644 index 253f6ba..0000000 --- a/pkg/service/delivery/generate_2fa.go +++ /dev/null @@ -1,18 +0,0 @@ -package delivery - -import ( - "context" - "errors" - "github.com/pquerna/otp/totp" -) - -func (deliverSrv *DeliveryService) GenerateTOTP(_ context.Context, phone string) (string, string, error) { - key, err := totp.Generate(totp.GenerateOpts{ - Issuer: "Food Delivery", - AccountName: phone, - }) - if err != nil { - return "", "", errors.New("error generating key") - } - return key.Secret(), key.URL(), nil -}