예제 #1
0
        private async void Browser_Navigating(object sender, WebNavigatingEventArgs e)
        {
            try
            {
                Uri liveUrl = new Uri(e.Url, UriKind.Absolute);
                if (liveUrl.AbsoluteUri.Contains("code="))
                {
                    if (Settings.GetSetting(CommonConstants.AuthCodeKey) != string.Empty)
                    {
                        MvpHelper.RemoveProperties();
                    }

                    var    regex     = new System.Text.RegularExpressions.Regex("code=([^&]+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    string auth_code = regex.Match(liveUrl.AbsoluteUri).Groups[1].Value;

                    Settings.SetSetting(CommonConstants.AuthCodeKey, auth_code);
                    await LiveIdLogOnViewModel.Instance.GetAccessToken();

                    var profileTest = await MvpHelper.MvpService.GetProfile(LogOnViewModel.StoredToken);

                    if (profileTest == null || profileTest.MvpId == 0)
                    {
                        Logger.Log("Login-Invalid");
                        await DisplayAlert(string.Empty, TranslateServices.GetResourceString(CommonConstants.DialogDescriptionForInvalidCredentials), TranslateServices.GetResourceString(CommonConstants.DialogOK));

                        App.CookieHelper.ClearCookie();
                        LiveIdLogOnViewModel.Instance.SignOut();
                        await Navigation.PopModalAsync(true);
                    }
                    else
                    {
                        Logger.Log("Login-Valid");

                        switch (Device.RuntimePlatform)
                        {
                        case Device.iOS:
                            Application.Current.MainPage = new MainTabPageiOS();
                            break;

                        default:
                            Application.Current.MainPage = new MVPNavigationPage(new MainTabPage())
                            {
                                Title = "Microsoft MVP"
                            };
                            break;
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                UserDialogs.Instance.Alert(exp.Message);
                App.CookieHelper.ClearCookie();
                LiveIdLogOnViewModel.Instance.SignOut();
                await Navigation.PushModalAsync(new LogOn());
            }
        }
예제 #2
0
        public void SignOut()
        {
            MvpHelper.RemoveProperties();
            LogOnViewModel.StoredToken = string.Empty;
            MyProfileViewModel.Instance.FirstAwardValue      = string.Empty;
            MyProfileViewModel.Instance.PersonName           = string.Empty;
            MyProfileViewModel.Instance.AwardCategoriesValue = string.Empty;
            MyProfileViewModel.Instance.Description          = string.Empty;
            MyProfileViewModel.Instance.AwardsCountValue     = string.Empty;

            MyProfileViewModel.Instance.StoreImageBase64Str = null;
            MyProfileViewModel.Instance.List = new ObservableRangeCollection <Models.ContributionModel>();
        }
예제 #3
0
        public void SignOut()
        {
            //Application.Current.Properties.Clear();
            MvpHelper.RemoveProperties();
            LogOnViewModel.StoredToken = string.Empty;
            MyProfileViewModel.Instance.FirstAwardValue      = string.Empty;
            MyProfileViewModel.Instance.PersonName           = string.Empty;
            MyProfileViewModel.Instance.AwardCategoriesValue = string.Empty;
            MyProfileViewModel.Instance.Description          = string.Empty;
            MyProfileViewModel.Instance.AwardsCountValue     = string.Empty;

            MyProfileViewModel.Instance.StoreImageBase64Str = null;
            MyProfileViewModel.Instance.List = new System.Collections.ObjectModel.ObservableCollection <Models.ContributionModel>();
        }
예제 #4
0
        private async void Browser_Navigating(object sender, WebNavigatingEventArgs e)
        {
            Uri liveUrl = new Uri(e.Url, UriKind.Absolute);

            if (liveUrl.AbsoluteUri.Contains("code="))
            {
                if (Settings.GetSetting(CommonConstants.AuthCodeKey) != string.Empty)
                {
                    MvpHelper.RemoveProperties();
                }

                string auth_code = System.Text.RegularExpressions.Regex.Split(liveUrl.AbsoluteUri, "code=")[1];
                Settings.SetSetting(CommonConstants.AuthCodeKey, auth_code);
                await LiveIdLogOnViewModel.Instance.GetAccessToken();

                var profileTest = await MvpHelper.MvpService.GetProfile(LogOnViewModel.StoredToken);

                if (profileTest == null || string.IsNullOrWhiteSpace(profileTest.DisplayName))
                {
                    Logger.Log("Login-Invalid");
                    await DisplayAlert(string.Empty, "Unable to validate MVP status, please login again with your MVP credentials.", "OK");

                    App.CookieHelper.ClearCookie();
                    LiveIdLogOnViewModel.Instance.SignOut();
                    await Navigation.PopModalAsync(true);
                }
                else
                {
                    Logger.Log("Login-Valid");

                    switch (Device.RuntimePlatform)
                    {
                    case Device.iOS:
                        Application.Current.MainPage = new MainTabPageiOS();
                        break;

                    default:
                        Application.Current.MainPage = new MVPNavigationPage(new MainTabPage())
                        {
                            Title = "Microsoft MVP"
                        };
                        break;
                    }
                }
            }
        }
예제 #5
0
        public void SignOut()
        {
            MvpHelper.RemoveProperties();

            if (Application.Current.Properties.ContainsKey(CommonConstants.ProfileCacheListKey))
            {
                Application.Current.Properties.Remove(CommonConstants.ProfileCacheListKey);
            }

            LogOnViewModel.StoredToken = string.Empty;
            MyProfileViewModel.Instance.FirstAwardValue      = string.Empty;
            MyProfileViewModel.Instance.PersonName           = string.Empty;
            MyProfileViewModel.Instance.AwardCategoriesValue = string.Empty;
            MyProfileViewModel.Instance.Description          = string.Empty;
            MyProfileViewModel.Instance.AwardsCountValue     = string.Empty;

            MyProfileViewModel.Instance.StoreImageBase64Str = null;
            MyProfileViewModel.Instance.List = new ObservableRangeCollection <Models.ContributionModel>();
        }
예제 #6
0
        private async void Browser_Navigating(object sender, WebNavigatingEventArgs e)
        {
            Uri liveUrl = new Uri(e.Url, UriKind.Absolute);

            if (liveUrl.AbsoluteUri.Contains("code="))
            {
                if (Application.Current.Properties.ContainsKey(CommonConstants.AuthCodeKey))
                {
                    //Application.Current.Properties.Clear();
                    MvpHelper.RemoveProperties();
                }

                string auth_code = System.Text.RegularExpressions.Regex.Split(liveUrl.AbsoluteUri, "code=")[1];
                Application.Current.Properties.Add(CommonConstants.AuthCodeKey, auth_code);
                await LiveIdLogOnViewModel.Instance.GetAccessToken();

                await Navigation.PushModalAsync(new MyProfile());
            }
        }