diff --git a/otp/handler/otp.go b/otp/handler/otp.go index d1ffdd9..92fea64 100644 --- a/otp/handler/otp.go +++ b/otp/handler/otp.go @@ -41,7 +41,7 @@ func (e *Otp) Generate(ctx context.Context, req *pb.GenerateRequest, rsp *pb.Gen key, err := totp.Generate(totp.GenerateOpts{ Issuer: "Micro", AccountName: req.Id, - Period: 300, + Period: uint(req.Expiry), Algorithm: otp.AlgorithmSHA1, }) if err != nil { @@ -54,7 +54,7 @@ func (e *Otp) Generate(ctx context.Context, req *pb.GenerateRequest, rsp *pb.Gen Expiry: uint(req.Expiry), } - if err := cache.Context(ctx).Set("otp:"+req.Id, okey, time.Now().Add(time.Minute*5)); err != nil { + if err := cache.Context(ctx).Set("otp:"+req.Id, okey, time.Now().Add(time.Second*time.Duration(req.Expiry))); err != nil { logger.Error("Failed to store secret: %v", err) return errors.InternalServerError("otp.generate", "failed to generate code") }