private async void DisconnectGoogleHandler() { if (SelectedProfile.SelectedGoogleAccount == null) { MessageService.ShowMessageAsync("No account selected"); return; } var dialogResult = await MessageService.ShowConfirmMessage( "Disconnection of Google account cannot be reverted.\nClick Yes to continue."); if (dialogResult == MessageDialogResult.Negative) { return; } var result = AccountAuthenticationService.DisconnectGoogle(SelectedProfile.SelectedGoogleAccount.Name); if (result) { //Remove google account var googleAccount = GoogleAccounts.FirstOrDefault(account => account.Name == SelectedProfile.SelectedGoogleAccount.Name); if (googleAccount != null) { foreach (var profileViewModel in SyncProfileList) { if (profileViewModel.SelectedGoogleAccount != null && profileViewModel.SelectedGoogleAccount.Name.Equals(googleAccount.Name)) { profileViewModel.SelectedGoogleAccount = null; profileViewModel.GoogleCalendars = null; profileViewModel.SelectedCalendar = null; } } GoogleAccounts.Remove(googleAccount); await MessageService.ShowMessage("Google account successfully disconnected"); foreach (var calendarSyncProfile in Settings.SyncProfiles) { if (calendarSyncProfile.GoogleAccount != null && calendarSyncProfile.GoogleAccount.Name.Equals(googleAccount.Name)) { calendarSyncProfile.GoogleAccount = null; } } await SettingsSerializationService.SerializeSettingsAsync(Settings); } } else { MessageService.ShowMessageAsync("Account wasn't authenticated earlier or disconnection failed."); } }
private TasksService GetTasksService(string accountName) { return(AccountAuthenticationService.AuthenticateTasksOauth(accountName)); }
/// <summary> /// </summary> private async void AddNewGoogleAccountHandler() { //Accept Email Id var accountName = await MessageService.ShowInput("Enter your Google Email", "Adding Google Account"); if (string.IsNullOrEmpty(accountName)) { return; } if (Settings.GoogleAccounts != null && Settings.GoogleAccounts.Any(t => t.Name.Equals(accountName, StringComparison.InvariantCultureIgnoreCase))) { MessageService.ShowMessageAsync("An account with the same email already exists. Please try again."); return; } //Create cancellation token to support cancellation var tokenSource = new CancellationTokenSource(); var token = tokenSource.Token; if (Settings.AllowManualAuthentication) { var authResult = await AccountAuthenticationService.ManualAccountAuthetication(accountName, tokenSource.Token, GetGoogleAuthCode); if (!authResult) { MessageService.ShowMessageAsync("Account Not Added, Authorization Interrupted, Try Again"); } else { AddGoogleAccountDetailsToApplication(accountName); } } else { // Start progress controller var progressDialogController = await MessageService.ShowProgress("Authenticate and Authorize in the browser window", "Add Google Account"); //Delay for Preparedness await Task.Delay(5000); progressDialogController.SetIndeterminate(); progressDialogController.SetCancelable(true); var authorizeGoogleAccountTask = AccountAuthenticationService.AuthorizeGoogleAccount(accountName, tokenSource.Token); //Wait for 120 seconds var timeInSeconds = 120; while (timeInSeconds > 0) { progressDialogController.SetMessage( $"Authenticate and Authorize in the browser window in {timeInSeconds} secs"); //cancel task if cancellation is requested if (progressDialogController.IsCanceled) { tokenSource.Cancel(); break; } //break loop if task changes its status if (authorizeGoogleAccountTask.IsCanceled || authorizeGoogleAccountTask.IsFaulted || authorizeGoogleAccountTask.IsCompleted) { break; } timeInSeconds--; await Task.Delay(1000, tokenSource.Token); } if (timeInSeconds < 0) { tokenSource.Cancel(); } await progressDialogController.CloseAsync(); if (authorizeGoogleAccountTask.IsCanceled || authorizeGoogleAccountTask.IsFaulted || tokenSource.Token.IsCancellationRequested || progressDialogController.IsCanceled) { MessageService.ShowMessageAsync("Account Not Added, Authorization Interrupted, Try Again"); } else { AddGoogleAccountDetailsToApplication(accountName); } } }
private async void DisconnectGoogleHandler(object parameter) { var googleAccount = parameter as GoogleAccount; if (googleAccount == null) { MessageService.ShowMessageAsync("No account selected"); return; } var accountName = googleAccount.Name; var dialogResult = await MessageService.ShowConfirmMessage( "Disconnection of Google account cannot be reverted.\nClick Yes to continue."); if (dialogResult == MessageDialogResult.Negative) { return; } var result = AccountAuthenticationService.DisconnectGoogle(googleAccount.Name); if (result) { foreach (var profile in Settings.CalendarSyncProfiles) { if (profile.GoogleSettings.GoogleAccount != null && profile.GoogleSettings.GoogleAccount.Name.Equals(googleAccount.Name)) { profile.GoogleSettings.GoogleAccount = null; profile.GoogleSettings.GoogleCalendar = null; profile.GoogleSettings.GoogleCalendars = null; } profile.IsLoaded = false; } //Remove google account googleAccount = Settings.GoogleAccounts.FirstOrDefault(account => account.Name == accountName); if (googleAccount != null) { Settings.GoogleAccounts.Remove(googleAccount); } googleAccount = LastSavedSettings.GoogleAccounts.FirstOrDefault(account => account.Name == accountName); if (googleAccount != null) { LastSavedSettings.GoogleAccounts.Remove(googleAccount); } await MessageService.ShowMessage("Google account successfully disconnected"); await SettingsSerializationService.SerializeSettingsAsync(LastSavedSettings); } else { MessageService.ShowMessageAsync("Account wasn't authenticated earlier or disconnection failed."); } }
private CalendarService GetCalendarService(string accountName) { return(AccountAuthenticationService.AuthenticateCalendarOauth(accountName)); }
public bool Login() { return(AccountAuthenticationService.Login(UserName, Password, RememberMe)); }
public AccountServiceProxyImpl(AccountCreationService accountCreationService, AccountAuthenticationService accountAuthenticationService, AccountLookupService accountLookupService) { this.accountCreationService = accountCreationService; this.accountAuthenticationService = accountAuthenticationService; this.accountLookupService = accountLookupService; }