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:
dahoud
2026-04-07 20:56:03 +00:00
parent 22f9c7e9a1
commit 70cbd1c873
63 changed files with 9316 additions and 6122 deletions

View File

@@ -10,18 +10,19 @@ import '../error/error_handler.dart';
import '../utils/logger.dart';
import '../../features/authentication/presentation/bloc/auth_bloc.dart';
import '../../features/authentication/data/datasources/keycloak_auth_service.dart';
import 'org_context_service.dart';
/// Client réseau unifié basé sur Dio (Version DRY & Minimaliste).
@lazySingleton
class ApiClient {
late final Dio _dio;
static const FlutterSecureStorage _storage = FlutterSecureStorage(
aOptions: AndroidOptions(encryptedSharedPreferences: true),
iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock_this_device),
);
ApiClient() {
ApiClient(OrgContextService orgContextService) {
_dio = Dio(
BaseOptions(
baseUrl: AppConfig.apiBaseUrl,
@@ -53,6 +54,11 @@ class ApiClient {
if (token != null) {
options.headers['Authorization'] = 'Bearer $token';
}
// Injecter l'organisation active si disponible
if (orgContextService.hasContext) {
options.headers[OrgContextService.headerName] =
orgContextService.activeOrganisationId;
}
return handler.next(options);
},
onError: (DioException e, handler) async {

View File

@@ -0,0 +1,70 @@
/// Service singleton qui maintient le contexte d'organisation actif.
///
/// Injecté dans [ApiClient] pour ajouter automatiquement le header
/// [X-Active-Organisation-Id] à chaque requête backend.
library org_context_service;
import 'package:injectable/injectable.dart';
import '../utils/logger.dart';
const _kHeaderActiveOrg = 'X-Active-Organisation-Id';
@lazySingleton
class OrgContextService {
String? _activeOrganisationId;
String? _activeOrganisationNom;
String? _activeOrganisationType;
Set<String> _modulesActifs = {};
/// L'UUID de l'organisation active (null si non sélectionnée).
String? get activeOrganisationId => _activeOrganisationId;
/// Le nom lisible de l'organisation active.
String? get activeOrganisationNom => _activeOrganisationNom;
/// Le type de l'organisation active (ex: ASSOCIATION, TONTINE...).
String? get activeOrganisationType => _activeOrganisationType;
/// Modules actifs de l'organisation active (en majuscules).
Set<String> get modulesActifs => Set.unmodifiable(_modulesActifs);
/// Nom du header HTTP utilisé par le backend.
static const String headerName = _kHeaderActiveOrg;
/// Indique si un contexte est disponible.
bool get hasContext => _activeOrganisationId != null;
/// Vérifie si un module spécifique est actif.
bool isModuleActif(String module) =>
_modulesActifs.contains(module.toUpperCase());
/// Définit l'organisation active.
void setActiveOrganisation({
required String organisationId,
required String nom,
String? type,
String? modulesActifsCsv,
}) {
_activeOrganisationId = organisationId;
_activeOrganisationNom = nom;
_activeOrganisationType = type;
_modulesActifs = _parseModules(modulesActifsCsv);
AppLogger.info(
'OrgContextService: organisation active → $nom ($organisationId)'
' | modules: $_modulesActifs');
}
/// Réinitialise le contexte (ex: à la déconnexion).
void clear() {
_activeOrganisationId = null;
_activeOrganisationNom = null;
_activeOrganisationType = null;
_modulesActifs = {};
AppLogger.info('OrgContextService: contexte org effacé');
}
Set<String> _parseModules(String? csv) {
if (csv == null || csv.isEmpty) return {};
return csv.split(',').map((m) => m.trim().toUpperCase()).toSet();
}
}