提交 1d37e613 authored 作者: mooncake9527's avatar mooncake9527

fix captcha

上级 f1026e38
......@@ -7,6 +7,11 @@ import (
"github.com/mojocn/base64Captcha"
"github.com/redis/go-redis/v9"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
const (
NotFoundPlaceholder = "*"
)
type Captcha struct {
......@@ -46,7 +51,10 @@ func (rs *RedisStore) Get(id string, clear bool) string {
key := rs.prefix + id
val, err := rs.client.Get(ctx, key).Result()
if err != nil {
panic(err)
if xerror.Is(err, redis.Nil) {
return ""
}
panic(xerror.New(err.Error()))
}
if clear {
go rs.client.Del(ctx, key)
......@@ -55,6 +63,9 @@ func (rs *RedisStore) Get(id string, clear bool) string {
if len(parts) != 2 {
return ""
}
if parts[0] == NotFoundPlaceholder { // 这块逻辑应该用不到
return ""
}
return parts[0]
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论