mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
make otp key expiry configurable
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user