31 lines
828 B
Go
31 lines
828 B
Go
package bcache
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
// 存储mfa验证码 KeyUserMfaCode:{uuid}
|
|
func SetUserMfaCode(ctx context.Context, uuid string, code string) error {
|
|
mfaKey := fmt.Sprintf(consts.KeyUserMfaCode, uuid)
|
|
_, err := g.Redis().Set(ctx, mfaKey, code)
|
|
return err
|
|
}
|
|
|
|
// 获取mfa验证码 KeyUserMfaCode:{uuid}
|
|
func GetUserMfaCode(ctx context.Context, uuid string) (string, error) {
|
|
mfaKey := fmt.Sprintf(consts.KeyUserMfaCode, uuid)
|
|
code, err := g.Redis().Get(ctx, mfaKey)
|
|
return code.String(), err
|
|
}
|
|
|
|
// 删除mfa验证码 KeyUserMfaCode:{uuid}
|
|
func DeleteUserMfaCode(ctx context.Context, uuid string) error {
|
|
mfaKey := fmt.Sprintf(consts.KeyUserMfaCode, uuid)
|
|
_, err := g.Redis().Del(ctx, mfaKey)
|
|
return err
|
|
}
|