feat: add error log for ValidateUserToken
This commit is contained in:
parent
81e6408217
commit
604262c500
@ -38,7 +38,10 @@ func ValidateUserToken(key string) (token *Token, err error) {
|
|||||||
return nil, errors.New("未提供令牌")
|
return nil, errors.New("未提供令牌")
|
||||||
}
|
}
|
||||||
token, err = CacheGetTokenByKey(key)
|
token, err = CacheGetTokenByKey(key)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
common.SysError("failed to get token" + err.Error())
|
||||||
|
return nil, errors.New("无效的令牌")
|
||||||
|
}
|
||||||
if token.Status == common.TokenStatusExhausted {
|
if token.Status == common.TokenStatusExhausted {
|
||||||
return nil, errors.New("该令牌额度已用尽")
|
return nil, errors.New("该令牌额度已用尽")
|
||||||
} else if token.Status == common.TokenStatusExpired {
|
} else if token.Status == common.TokenStatusExpired {
|
||||||
@ -70,8 +73,6 @@ func ValidateUserToken(key string) (token *Token, err error) {
|
|||||||
}
|
}
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("无效的令牌")
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetTokenByIds(id int, userId int) (*Token, error) {
|
func GetTokenByIds(id int, userId int) (*Token, error) {
|
||||||
if id == 0 || userId == 0 {
|
if id == 0 || userId == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user