internal static bool HandleHttpException(HttpException ex, string message, INavigationService navigationService, ILog log) { if (ex.StatusCode == HttpStatusCode.Unauthorized) { MessageBox.Show(AppResources.ErrorDisabledUser, AppResources.ErrorDisabledUserTitle, MessageBoxButton.OK); log.Error("UnauthorizedAccess for user [{0}]", AuthenticationService.Current.LoggedInUser.Name); navigationService.NavigateTo(Constants.Pages.ChooseProfileView); return(true); } log.ErrorException(message, ex); return(false); }
internal static async Task HandleConnectedState( ConnectionResult result, IApiClient apiClient, INavigationService navigationService, ILog log) { var page = TileService.Current.PinnedPage(); switch (result.State) { case ConnectionState.Unavailable: App.ShowMessage(AppResources.ErrorCouldNotFindServer); navigationService.NavigateTo(Constants.Pages.FirstRun.MbConnectFirstRunView); break; case ConnectionState.ServerSelection: navigationService.NavigateTo(Constants.Pages.SettingsViews.FindServerView); break; case ConnectionState.ServerSignIn: if (AuthenticationService.Current.LoggedInUser == null) { navigationService.NavigateTo(Constants.Pages.ChooseProfileView); } else { AuthenticationService.Current.SetAuthenticationInfo(); navigationService.NavigateTo(page, true); } break; case ConnectionState.SignedIn: if (AuthenticationService.Current.LoggedInUser == null) { var user = await apiClient.GetUserAsync(apiClient.CurrentUserId); AuthenticationService.Current.SetUser(user); AuthenticationService.Current.SetAccessToken(apiClient.AccessToken); } if (AuthenticationService.Current.AuthenticationResult == null) { AuthenticationService.Current.SetAccessToken(apiClient.AccessToken); } await StartEverything(navigationService, log, apiClient); navigationService.NavigateTo(page, true); break; case ConnectionState.ConnectSignIn: navigationService.NavigateTo(Constants.Pages.FirstRun.MbConnectFirstRunView); break; } }