public override async void OnAppear(params object[] args) { if (string.IsNullOrWhiteSpace(_settingServicce.Token)) { _nav.Init <LoginViewModel>(); } else { _httpFactory.LoggedIn(_settingServicce.Token); var res = await _memberHandler.TouchLogin(); if (res == null) { _settingServicce.Token = string.Empty; _httpFactory.Logout(); _nav.NavigateTo <LoginViewModel>(); } else { AppService.CurrentUser = res; AppService.HasCRRole = res.ClassRepresentative; _nav.Init <HomeViewModel>(); if (AppService.CurrentUser.Batch != null) { _platformService.SubsubcribeTopics(AppService.CurrentUser.Batch.Name); } } } }
internal async Task <DBUser> GetUser() { try { if (string.IsNullOrWhiteSpace(_currentToken)) { if (await _localData.ContainKeyAsync(tokenKey)) { _currentToken = await _localData.GetItemAsync <string>(tokenKey); } } } catch { } if (!string.IsNullOrWhiteSpace(_currentToken)) { _httpWorker.LoggedIn(_currentToken); if (CurrentUser != null) { return(CurrentUser); } try { var user = await _sessionData.GetItemAsync <DBUser>(tokenUser); if (user != null) { CurrentUser = user; return(user); } } catch { } var res = await _memberHandler.TouchLogin(); if (res == null) { await Logout(); return(null); } else { CurrentUser = res; await _sessionData.SetItemAsync(tokenUser, CurrentUser); return(res); } } Console.WriteLine("Asking For Info: " + _currentToken); return(null); }