feat: normalize user ID in auth envelope and update hub manager assignment logic

This commit is contained in:
Achintha Isuru
2026-03-17 14:47:01 -04:00
parent e2d833dc58
commit a12539ba07
3 changed files with 23 additions and 8 deletions

View File

@@ -190,7 +190,20 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
envelope['business'] as Map<String, dynamic>?;
if (businessJson != null) {
final ClientSession clientSession = ClientSession.fromJson(envelope);
// The auth envelope from buildAuthEnvelope uses `user.id` but
// ClientSession.fromJson expects `user.userId` (matching the shape
// returned by loadActorContext / GET /client/session). Normalise the
// key so the session is populated correctly.
final Map<String, dynamic> normalisedEnvelope = <String, dynamic>{
...envelope,
if (userJson != null)
'user': <String, dynamic>{
...userJson,
'userId': userJson['id'] ?? userJson['userId'],
},
};
final ClientSession clientSession =
ClientSession.fromJson(normalisedEnvelope);
ClientSessionStore.instance.setSession(clientSession);
}