Esempio n. 1
0
        public static async Task DoLoginAsync(Settings.AuthOption authOption)
        {
            if (authOption == Settings.AuthOption.GuestAccess)
            {
                Settings.Current.CurrentUserId = Settings.Current.DefaultUserId;
                return; // can't authenticate
            }

            var mobileClient = DependencyService.Get <IPlatform>();

            var user =
                authOption == Settings.AuthOption.Facebook ?
                await mobileClient.LoginFacebookAsync() :
                await mobileClient.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);

            App.Instance.AuthenticatedUser = user;
            System.Diagnostics.Debug.WriteLine("Authenticated with user: "******"ManageUser",
                    System.Net.Http.HttpMethod.Get,
                    null);

            Debug.WriteLine($"Set current userID to: {Settings.Current.CurrentUserId}");

            AuthStore.CacheAuthToken(user);
        }
        private async Task LoginComplete(Settings.AuthOption option)
        {
            DependencyService.Get <IPlatform>().LogEvent("Login" + option);

            await Navigation.PopModalAsync();

            tcs.TrySetResult(option);
        }
 private async Task DoLoginAsync(Settings.AuthOption authOption)
 {
     try
     {
         await AuthHandler.DoLoginAsync(authOption);
         await LoginComplete(authOption);
     }
     catch (Exception)
     {
         // if user cancels, then set to Guest access
         await LoginComplete(Settings.AuthOption.GuestAccess);
     }
 }