This commit is contained in:
zhaoxiaorong 2025-02-11 13:19:07 +08:00
parent fd967b8c1d
commit f1310d093e
1 changed files with 3 additions and 3 deletions

View File

@ -21,13 +21,13 @@ var (
JwtSecretLen int JwtSecretLen int
) )
func New(token string) { func New(secret string) {
JwtSecret = []byte(token) JwtSecret = []byte(secret)
JwtSecretLen = len(env.Runtime.JwtSecretKey) JwtSecretLen = len(env.Runtime.JwtSecretKey)
} }
func GenerateTokenAes(id uint, identity, client, role string, owner any, extend map[string]string) (string, error) { func GenerateTokenAes(id uint, identity, client, role string, owner any, extend map[string]string) (string, error) {
if (JwtSecretLen == 16 || JwtSecretLen == 24 || JwtSecretLen == 32) == false { if !(JwtSecretLen == 16 || JwtSecretLen == 24 || JwtSecretLen == 32) {
return "", errcode.ErrJWTSecretKey return "", errcode.ErrJWTSecretKey
} }
expireTime := time.Now().Add(vars.JwtExpireDay) expireTime := time.Now().Add(vars.JwtExpireDay)