在线设备的时间

pull/3727/head
hawklin2017 2 weeks ago
parent 58defe6373
commit 1a0f0fdfbf

@ -311,14 +311,27 @@ func (s *authServer) GetActiveDevices(ctx context.Context, req *pbauth.GetActive
if err != nil {
return nil, err
}
for _, state := range m {
if state == constant.NormalToken {
devices = append(devices, &pbauth.DeviceInfo{
PlatformID: int32(platformID),
PlatformName: platformName,
})
break
var maxLoginUnix int64
var hasNormal bool
for tokenStr, state := range m {
if state != constant.NormalToken {
continue
}
hasNormal = true
claims, err := tokenverify.GetClaimFromToken(tokenStr, authverify.Secret(s.config.Share.Secret))
if err != nil || claims.IssuedAt == nil {
continue
}
if u := claims.IssuedAt.Unix(); u > maxLoginUnix {
maxLoginUnix = u
}
}
if hasNormal {
devices = append(devices, &pbauth.DeviceInfo{
PlatformID: int32(platformID),
PlatformName: platformName,
LoginTimeSeconds: maxLoginUnix,
})
}
}
return &pbauth.GetActiveDevicesResp{Devices: devices}, nil

@ -1 +1 @@
Subproject commit 510b9a7dc27703beab55334622e4ecf17b8a4d50
Subproject commit 7bd25d8024043c6f8ebd4c6d473a89e7034e639d
Loading…
Cancel
Save