feat: self-connection blocking API support (token-device internal endpoint, jti)

This commit is contained in:
admin committed 2026-09-16 13:33:27 +08:00
1 parent 37b9991d0e
commit 9e34bdce9e
6 files changed
+73 -1

No files matched your search

+10
View File
@@ -85,6 +85,16 @@ func (us *UserService) InfoByAccessToken(token string) (*model.User, *model.User
return u, ut
}
// GetDeviceIdByToken 根据token查询登录设备ID,供hbbs自连拦截内部调用
func (us *UserService) GetDeviceIdByToken(token string) string {
ut := &model.UserToken{}
DB.Where("token = ?", token).First(ut)
if ut.Id == 0 || ut.ExpiredAt < time.Now().Unix() {
return ""
}
return ut.DeviceId
}
// GenerateToken 生成token
func (us *UserService) GenerateToken(u *model.User) string {
if len(Jwt.Key) > 0 {