feat: self-connection blocking API support (token-device internal endpoint, jti)
This commit is contained in:
1 parent
37b9991d0e
commit
9e34bdce9e
6 files changed
+73
-1
No files matched your search
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user