fix UseWithCtx method to check for nil context

- Add nil check for context parameter.
- UseWithCtx method return explicit type rather than interface.

Replace base64Captcha.Store return type with *RedisStore for better type safety.
This commit is contained in:
huiyifyj
2025-04-01 16:26:31 +08:00
parent 9806f72ca6
commit 83eb193f1b

View File

@@ -5,7 +5,6 @@ import (
"time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/mojocn/base64Captcha"
"go.uber.org/zap"
)
@@ -23,8 +22,10 @@ type RedisStore struct {
Context context.Context
}
func (rs *RedisStore) UseWithCtx(ctx context.Context) base64Captcha.Store {
rs.Context = ctx
func (rs *RedisStore) UseWithCtx(ctx context.Context) *RedisStore {
if ctx == nil {
rs.Context = ctx
}
return rs
}