feat: normalize user ID in auth envelope and update hub manager assignment logic
This commit is contained in:
@@ -190,7 +190,20 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
|
|||||||
envelope['business'] as Map<String, dynamic>?;
|
envelope['business'] as Map<String, dynamic>?;
|
||||||
|
|
||||||
if (businessJson != null) {
|
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);
|
ClientSessionStore.instance.setSession(clientSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,11 +142,13 @@ class HubRepositoryImpl implements HubRepositoryInterface {
|
|||||||
required String hubId,
|
required String hubId,
|
||||||
required List<String> businessMembershipIds,
|
required List<String> businessMembershipIds,
|
||||||
}) async {
|
}) async {
|
||||||
await _apiService.post(
|
for (final String membershipId in businessMembershipIds) {
|
||||||
ClientEndpoints.hubAssignManagers(hubId),
|
await _apiService.post(
|
||||||
data: <String, dynamic>{
|
ClientEndpoints.hubAssignManagers(hubId),
|
||||||
'businessMembershipIds': businessMembershipIds,
|
data: <String, dynamic>{
|
||||||
},
|
'businessMembershipId': membershipId,
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class ClientOrderQueryRepositoryImpl
|
|||||||
id: role['roleId'] as String? ?? role['id'] as String? ?? '',
|
id: role['roleId'] as String? ?? role['id'] as String? ?? '',
|
||||||
name: role['roleName'] as String? ?? role['name'] as String? ?? '',
|
name: role['roleName'] as String? ?? role['name'] as String? ?? '',
|
||||||
costPerHour:
|
costPerHour:
|
||||||
((role['billRateCents'] as num?)?.toDouble() ?? 0) / 100.0,
|
((role['hourlyRateCents'] as num?)?.toDouble() ?? 0) / 100.0,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user