feat(token): enhance error handling in ValidateUserToken for better clarity
This commit is contained in:
parent
4bcdb1ec07
commit
d488a19ed7
@ -112,7 +112,12 @@ func ValidateUserToken(key string) (token *Token, err error) {
|
|||||||
}
|
}
|
||||||
return token, nil
|
return token, nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("无效的令牌")
|
common.SysLog("ValidateUserToken: failed to get token: " + err.Error())
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, errors.New("无效的令牌")
|
||||||
|
} else {
|
||||||
|
return nil, errors.New("无效的令牌,数据库查询出错,请联系管理员")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetTokenByIds(id int, userId int) (*Token, error) {
|
func GetTokenByIds(id int, userId int) (*Token, error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user