fix(mobile): URL changement mdp corrigée + v3.0 — multi-org, AppAuth, sécurité prod
Auth: - profile_repository.dart: /api/auth/change-password → /api/membres/auth/change-password Multi-org (Phase 3): - OrgSelectorPage, OrgSwitcherBloc, OrgSwitcherEntry - org_context_service.dart: headers X-Active-Organisation-Id + X-Active-Role Navigation: - MorePage: navigation conditionnelle par typeOrganisation - Suppression adaptive_navigation (remplacé par main_navigation_layout) Auth AppAuth: - keycloak_webview_auth_service: fixes AppAuth Android - AuthBloc: gestion REAUTH_REQUIS + premierLoginComplet Onboarding: - Nouveaux états: payment_method_page, onboarding_shared_widgets - SouscriptionStatusModel mis à jour StatutValidationSouscription Android: - build.gradle: ProGuard/R8, network_security_config - Gradle wrapper mis à jour
This commit is contained in:
@@ -25,8 +25,10 @@ abstract class WebSocketEvent {
|
||||
|
||||
factory WebSocketEvent.fromJson(Map<String, dynamic> json) {
|
||||
final eventType = json['eventType'] as String;
|
||||
final timestamp = DateTime.parse(json['timestamp'] as String);
|
||||
final data = json['data'] as Map<String, dynamic>;
|
||||
final timestamp = json['timestamp'] != null
|
||||
? DateTime.parse(json['timestamp'] as String)
|
||||
: DateTime.now();
|
||||
final data = (json['data'] as Map<String, dynamic>?) ?? <String, dynamic>{};
|
||||
|
||||
switch (eventType) {
|
||||
case 'APPROVAL_PENDING':
|
||||
@@ -242,6 +244,26 @@ class WebSocketService {
|
||||
return '$baseUrl/ws/dashboard';
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Helpers de conversion de types (Flutter Web / dart2js compatibility)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Convertit récursivement un objet JSON (potentiellement JS) en types Dart natifs.
|
||||
/// Nécessaire sur Flutter Web où jsonDecode peut retourner des LegacyJavaScriptObject.
|
||||
static dynamic _toDart(dynamic value) {
|
||||
if (value is Map) {
|
||||
return Map<String, dynamic>.fromEntries(
|
||||
(value as Map).entries.map(
|
||||
(e) => MapEntry(e.key.toString(), _toDart(e.value)),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (value is List) {
|
||||
return (value as List).map(_toDart).toList();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Gestion des messages reçus
|
||||
void _onMessage(dynamic message) {
|
||||
try {
|
||||
@@ -249,12 +271,25 @@ class WebSocketService {
|
||||
AppLogger.debug('WebSocket message reçu: $message');
|
||||
}
|
||||
|
||||
final json = jsonDecode(message as String) as Map<String, dynamic>;
|
||||
// Sur Flutter Web (web_socket_channel ^3.0.x avec package:web), les messages
|
||||
// text peuvent arriver comme JSString/LegacyJavaScriptObject plutôt que String.
|
||||
// toString() fonctionne pour les strings JS primitifs.
|
||||
final String rawMessage = message is String ? message : message.toString();
|
||||
if (rawMessage.isEmpty) return;
|
||||
|
||||
// Convertir en types Dart natifs pour éviter les LegacyJavaScriptObject imbriqués
|
||||
final dynamic decoded = jsonDecode(rawMessage);
|
||||
if (decoded is! Map) {
|
||||
AppLogger.warning('WebSocket: message ignoré (non-objet): type=${decoded.runtimeType}');
|
||||
return;
|
||||
}
|
||||
final json = _toDart(decoded) as Map<String, dynamic>;
|
||||
final type = json['type'] as String?;
|
||||
|
||||
// Gérer les messages système
|
||||
if (type == 'connected') {
|
||||
AppLogger.info('🔗 WebSocket: ${json['data']['message']}');
|
||||
final connectedMsg = (json['data'] as Map<String, dynamic>?)?['message'] ?? 'WebSocket connecté';
|
||||
AppLogger.info('🔗 WebSocket: $connectedMsg');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user