修复 redis 获取

This commit is contained in:
xmdhs 2023-10-11 23:26:01 +08:00
parent 5a9f16d1ae
commit eed2c1ccf5
3 changed files with 10 additions and 6 deletions

4
db/cache/redis.go vendored
View File

@ -4,6 +4,7 @@ package cache
import (
"context"
"errors"
"fmt"
"time"
@ -35,6 +36,9 @@ func (r *RedisCache) Del(k []byte) error {
func (r *RedisCache) Get(k []byte) ([]byte, error) {
value, err := r.c.Get(context.Background(), string(k)).Bytes()
if err != nil {
if errors.Is(err, redis.Nil) {
return nil, nil
}
return nil, fmt.Errorf("RedisCache.Get: %w", err)
}
return value, nil

View File

@ -33,7 +33,6 @@ type TokenClaims struct {
type Captcha struct {
Type string `json:"type"`
SiteKey string `json:"siteKey"`
ServerName string `json:"serverName"`
}
type UserInfo struct {
@ -62,6 +61,7 @@ type ChangeName struct {
type Config struct {
Captcha Captcha `json:"captcha"`
AllowChangeName bool
ServerName string `json:"serverName"`
}
type EditUser struct {

View File

@ -17,8 +17,8 @@ func (w *WebService) GetConfig(ctx context.Context) model.Config {
Captcha: model.Captcha{
Type: w.config.Captcha.Type,
SiteKey: w.config.Captcha.SiteKey,
ServerName: w.config.ServerName,
},
ServerName: w.config.ServerName,
AllowChangeName: !w.config.OfflineUUID,
}
}