feat(auth): restore authenticated user profile

This commit is contained in:
SaidSoighiri94
2026-07-23 14:39:35 +02:00
parent dc208fa13a
commit 36224f30ee
8 changed files with 276 additions and 76 deletions
@@ -1,3 +1,4 @@
import "../models/authenticated_profile.dart";
import "msal_bridge.dart";
enum AuthenticationMode { demo, azure }
@@ -19,8 +20,11 @@ class AuthService {
static const String demoResponsableEmail = "karim.benali@ensup.eu";
static String? _demoEmail;
static AuthenticatedProfile? _currentProfile;
static bool _azureInitialized = false;
static AuthenticatedProfile? get currentProfile => _currentProfile;
static AuthenticationMode get mode {
return switch (_configuredMode) {
"demo" => AuthenticationMode.demo,
@@ -41,6 +45,13 @@ class AuthService {
static void clearSession() {
_demoEmail = null;
_currentProfile = null;
}
static AuthenticatedProfile setProfileFromApi(dynamic reponse) {
final profile = AuthenticatedProfile.fromApi(reponse);
_currentProfile = profile;
return profile;
}
static Future<void> signInWithMicrosoft() async {
@@ -57,6 +68,7 @@ class AuthService {
if (mode == AuthenticationMode.azure) {
await _initializeAzure();
await MsalBridge.signOut();
_currentProfile = null;
return;
}