forked from baron/baron-sso
fix: clear stale auth flags and improve user name fallback logic (#637)
- Clear AuthTokenStore in _silentSessionRecovery when session is invalid (Case 2) - Use .trim().isNotEmpty for userName fallback to handle empty strings (Case 1)
This commit is contained in:
@@ -846,11 +846,13 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
|||||||
final profileState = ref.watch(profileProvider);
|
final profileState = ref.watch(profileProvider);
|
||||||
final profile = profileState.value;
|
final profile = profileState.value;
|
||||||
final timelineState = ref.watch(authTimelineProvider);
|
final timelineState = ref.watch(authTimelineProvider);
|
||||||
final userName =
|
final userName = (profile?.name.trim().isNotEmpty ?? false)
|
||||||
profile?.name ??
|
? profile!.name
|
||||||
profile?.email ??
|
: (profile?.email.trim().isNotEmpty ?? false)
|
||||||
profile?.phone ??
|
? profile!.email
|
||||||
tr('ui.userfront.profile.user_fallback', fallback: 'User');
|
: (profile?.phone.trim().isNotEmpty ?? false)
|
||||||
|
? profile!.phone
|
||||||
|
: tr('ui.userfront.profile.user_fallback', fallback: 'User');
|
||||||
final departmentValue =
|
final departmentValue =
|
||||||
profile?.tenant?.name ?? profile?.department ?? '';
|
profile?.tenant?.name ?? profile?.department ?? '';
|
||||||
final department = departmentValue.isNotEmpty
|
final department = departmentValue.isNotEmpty
|
||||||
|
|||||||
@@ -104,11 +104,13 @@ Future<void> _silentSessionRecovery() async {
|
|||||||
_log.info("[SessionRecovery] Recovery complete. Subject: $subject");
|
_log.info("[SessionRecovery] Recovery complete. Subject: $subject");
|
||||||
} else {
|
} else {
|
||||||
_log.warning("[SessionRecovery] Session found but subject is empty.");
|
_log.warning("[SessionRecovery] Session found but subject is empty.");
|
||||||
|
AuthTokenStore.clear();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_log.info(
|
_log.info(
|
||||||
"[SessionRecovery] No valid cookie session found or request failed: $e",
|
"[SessionRecovery] No valid cookie session found or request failed: $e",
|
||||||
);
|
);
|
||||||
|
AuthTokenStore.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user