handleAuthenticated method
Public handler for auth state changes. Called when user authenticates.
Can be passed to AuthService constructor for race-free initialization. See plan.auth-race.md for usage patterns.
Unlike DeviceService, NotificationService's _handleLogin doesn't actually
need _authService (it only uses configuration and local state). However,
the defensive warning helps surface initialization ordering issues.
Implementation
Future<void> handleAuthenticated(String? uid) async {
// Defensive check - warn if called before initialize().
// Unlike DeviceService, NotificationService's _handleLogin() doesn't actually
// need _authService (it only uses configuration and local state). However,
// logging helps surface initialization ordering issues.
if (_authService == null) {
logw('NotificationService: handleAuthenticated called before initialize(). '
'Proceeding anyway (_handleLogin has no auth dependency). '
'This may indicate an initialization ordering issue - see Constraint 2 in plan.auth-race.md');
}
logd('NotificationService: handleAuthenticated called, uid=$uid');
await _handleLogin();
}