feat(auth): restore authenticated user profile
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user