resolveUser method
- bool notify = false,
The current authenticated user, fetched from the API or cache.
Tries the API first; falls back to the cached user if the request fails. Returns UserModel.empty when neither is available.
When notify is true a successful API fetch broadcasts the user on
UserRepository.user. Defaults to false.
Implementation
Future<UserModel> resolveUser({bool notify = false}) async {
try {
return await _userRepository.getUser(notify: notify);
} catch (e) {
_logger.warn('[AuthRepository] API user fetch failed, trying cache', error: e);
}
final UserModel? cached = await _userRepository.getCachedUser();
if (cached != null) {
_logger.info('[AuthRepository] Using cached user');
return cached;
}
_logger.warn('[AuthRepository] No user available, returning empty');
return UserModel.empty;
}