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