This commit is contained in:
Asim Aslam
2021-12-04 22:20:57 +00:00
parent a29ccf37a0
commit 6a078b4176

View File

@@ -36,7 +36,7 @@ func (e *Otp) Generate(ctx context.Context, req *pb.GenerateRequest, rsp *pb.Gen
req.Size = 6
}
if err := cache.Context(ctx).Get("otp:"+req.Id, &okey); err != nil || okey == nil {
if _, err := cache.Context(ctx).Get("otp:"+req.Id, &okey); err != nil || okey == nil {
// generate a key
key, err := totp.Generate(totp.GenerateOpts{
Issuer: "Micro",
@@ -100,7 +100,7 @@ func (e *Otp) Validate(ctx context.Context, req *pb.ValidateRequest, rsp *pb.Val
key := new(otpKey)
if err := cache.Context(ctx).Get("otp:"+req.Id, &key); err != nil {
if _, err := cache.Context(ctx).Get("otp:"+req.Id, &key); err != nil {
logger.Error("Failed to get secret from store: %v", err)
return errors.InternalServerError("otp.generate", "failed to validate code")
}