public Authenticator() { try { _userService = AppAutoFac.Resolve <IUserService>(); } catch (Exception ex) { ex.ToString(); throw; } _client = AppAutoFac.Resolve <IMobileServiceClient>(); }
public static void NavigateToHomePage() { try { var detailPage = AppAutoFac.ResolvedIViewFactory.Resolve <MainPageViewModel>(); var masterDetails = new MasterDetailPage { Master = AppAutoFac.ResolvedIViewFactory.Resolve <MenuPageViewModel>(), Detail = new NavigationPage(detailPage) { BarTextColor = Color.Black } }; masterDetails.SetBinding(MasterDetailPage.IsPresentedProperty, "IsPresented", BindingMode.TwoWay); masterDetails.BindingContext = AppAutoFac.Resolve <MasterDetailPageViewModel>(); Application.Current.MainPage = masterDetails; } catch (Exception e) { } }
protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { if (this._client == null) { _client = AppAutoFac.Resolve <IMobileServiceClient>(); //throw new InvalidOperationException("Make sure to set the 'Client' property in this handler before using it."); } // Cloning the request, in case we need to send it again var clonedRequest = await CloneRequestAsync(request); var response = await base.SendAsync(clonedRequest, cancellationToken); if (response.StatusCode == HttpStatusCode.Unauthorized) { try { var authenticator = AppAutoFac.Resolve <IAuthenticator>(); await authenticator.AuthenticateAsync(new LoginObject()); clonedRequest = await CloneRequestAsync(request); clonedRequest.Headers.Remove("X-ZUMO-AUTH"); clonedRequest.Headers.Add("X-ZUMO-AUTH", _client.CurrentUser.MobileServiceAuthenticationToken); // Resend the request response = await base.SendAsync(clonedRequest, cancellationToken); } catch (InvalidOperationException) { // user cancelled auth, so return the original response return(response); } } return(response); }
public Authenticator() { _userService = AppAutoFac.Resolve <IUserService>(); _client = AppAutoFac.Resolve <IMobileServiceClient>(); }
public async Task Unauthenticate() { await _client.LogoutAsync(); await AppAutoFac.Resolve <ISyncService>().PurgeDataAsync(); }