Пример #1
0
        public void OnExternalLogin()
        {
            WebView.Navigating += async(s, e) =>
            {
                if (
                    e.Url.StartsWith(Settings.Settings.Url + Settings.Settings.ExternalLoginFailurePath))
                {
                    e.Cancel          = true;
                    StateLabel.Text   = "Login Failure";
                    WebView.IsVisible = false;
                    BackBtn.IsVisible = true;
                }
                if (
                    e.Url.StartsWith(Settings.Settings.Url + Settings.Settings.ExternalLoginFinalPath))
                {
                    WebView.IsVisible = false;
                    var result = await AccountService.ExternalLogin(e.Url);

                    if (result)
                    {
                        NotesHelper.ClearLocal(new NoteService(Settings.Settings.DatabaseName));
                        UserSettings.SyncDate = DateTime.MinValue.ToString("G");
                        var page = new NotePage(AccountService, NotesService);
                        Application.Current.MainPage = new NavigationPage(page);
                    }
                    else
                    {
                        StateLabel.Text   = "Login Failure";
                        BackBtn.IsVisible = true;
                    }
                }
            };
        }
Пример #2
0
 public async Task Logout()
 {
     using (var client = AuthHelper.GetAuthHttpClient())
     {
         await client.GetAsync(Settings.Settings.Url + Settings.Settings.LogoutPath).ConfigureAwait(false);
     }
     AuthHelper.ClearAll();
     NotesHelper.ClearLocal(new NoteService(Settings.Settings.DatabaseName));
 }