feat(auth): add device session tracking with configurable limits
Track authenticated sessions per device (parsing user-agent for desktop vs mobile via mileusna/useragent), enforce configurable concurrent device limits (Auth.DeviceLimits), and surface device status and "remove other devices" management in the account dialog. Adds device/session context to the auth module stores and exposes limits through the API. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
authmodule "img_infinite_canvas/internal/modules/auth"
|
||||
"img_infinite_canvas/internal/types"
|
||||
)
|
||||
@@ -93,7 +95,7 @@ func toAPIAccountDevices(devices []authmodule.Device) []types.AccountDevice {
|
||||
System: device.System,
|
||||
Browser: device.Browser,
|
||||
Client: device.Client,
|
||||
LastSeenAt: device.LastSeenAt.UTC().Format("2006-01-02 15:04(UTC)"),
|
||||
LastSeenAt: device.LastSeenAt.UTC().Format(time.RFC3339),
|
||||
})
|
||||
}
|
||||
return items
|
||||
|
||||
@@ -32,5 +32,12 @@ func (l *ListAccountDevicesLogic) ListAccountDevices() (resp *types.AccountDevic
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.AccountDeviceListResponse{Devices: toAPIAccountDevices(devices)}, nil
|
||||
limits := l.svcCtx.AuthService.DeviceLimits()
|
||||
return &types.AccountDeviceListResponse{
|
||||
Devices: toAPIAccountDevices(devices),
|
||||
Limits: types.AccountDeviceLimits{
|
||||
Desktop: limits.Desktop,
|
||||
Mobile: limits.Mobile,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user