diff --git a/Wino.Core.Domain/Interfaces/IAuthenticatorTypes.cs b/Wino.Core.Domain/Interfaces/IAuthenticatorTypes.cs index 51f1fd80..cb8a12e8 100644 --- a/Wino.Core.Domain/Interfaces/IAuthenticatorTypes.cs +++ b/Wino.Core.Domain/Interfaces/IAuthenticatorTypes.cs @@ -1,6 +1,9 @@ namespace Wino.Core.Domain.Interfaces { public interface IOutlookAuthenticator : IAuthenticator { } - public interface IGmailAuthenticator : IAuthenticator { } + public interface IGmailAuthenticator : IAuthenticator + { + bool ProposeCopyAuthURL { get; set; } + } public interface IImapAuthenticator : IAuthenticator { } } diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 43c44b18..0dce80f3 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -4,6 +4,10 @@ "AccountCreationDialog_PreparingFolders": "We are getting folder information at the moment.", "AccountCreationDialog_SigninIn": "Account information is being saved.", "AccountCreationDialog_FetchingProfileInformation": "Fetching profile details.", + "AccountCreationDialog_GoogleAuthHelpClipboardText_Row0": "If your browser did not launch automatically to complete authentication:", + "AccountCreationDialog_GoogleAuthHelpClipboardText_Row1": "1) Click the button below to copy the authentication address", + "AccountCreationDialog_GoogleAuthHelpClipboardText_Row2": "2) Launch your web browser (Edge, Chrome, Firefox etc...)", + "AccountCreationDialog_GoogleAuthHelpClipboardText_Row3": "3) Paste the copied address and go to the website to complete authentication manually.", "AccountEditDialog_Message": "Account Name", "AccountEditDialog_Title": "Edit Account", "AccountPickerDialog_Title": "Pick an account", diff --git a/Wino.Core.Domain/Translator.Designer.cs b/Wino.Core.Domain/Translator.Designer.cs index 480c4ddb..e526cf8e 100644 --- a/Wino.Core.Domain/Translator.Designer.cs +++ b/Wino.Core.Domain/Translator.Designer.cs @@ -43,6 +43,26 @@ namespace Wino.Core.Domain /// public static string AccountCreationDialog_FetchingProfileInformation => Resources.GetTranslatedString(@"AccountCreationDialog_FetchingProfileInformation"); + /// + /// If your browser did not launch automatically to complete authentication: + /// + public static string AccountCreationDialog_GoogleAuthHelpClipboardText_Row0 => Resources.GetTranslatedString(@"AccountCreationDialog_GoogleAuthHelpClipboardText_Row0"); + + /// + /// 1) Click the button below to copy the authentication address + /// + public static string AccountCreationDialog_GoogleAuthHelpClipboardText_Row1 => Resources.GetTranslatedString(@"AccountCreationDialog_GoogleAuthHelpClipboardText_Row1"); + + /// + /// 2) Launch your web browser (Edge, Chrome, Firefox etc...) + /// + public static string AccountCreationDialog_GoogleAuthHelpClipboardText_Row2 => Resources.GetTranslatedString(@"AccountCreationDialog_GoogleAuthHelpClipboardText_Row2"); + + /// + /// 3) Paste the copied address and go to the website to complete authentication manually. + /// + public static string AccountCreationDialog_GoogleAuthHelpClipboardText_Row3 => Resources.GetTranslatedString(@"AccountCreationDialog_GoogleAuthHelpClipboardText_Row3"); + /// /// Account Name /// diff --git a/Wino.Core.UWP/Services/NativeAppService.cs b/Wino.Core.UWP/Services/NativeAppService.cs index 2d8089ca..00e59663 100644 --- a/Wino.Core.UWP/Services/NativeAppService.cs +++ b/Wino.Core.UWP/Services/NativeAppService.cs @@ -156,7 +156,9 @@ namespace Wino.Services await taskbarManager.RequestPinCurrentAppAsync(); } - public async Task GetAuthorizationResponseUriAsync(IAuthenticator authenticator, string authorizationUri, CancellationToken cancellationToken = default) + public async Task GetAuthorizationResponseUriAsync(IAuthenticator authenticator, + string authorizationUri, + CancellationToken cancellationToken = default) { if (authorizationCompletedTaskSource != null) { diff --git a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs index 6a36e33a..4a7666c3 100644 --- a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs +++ b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs @@ -18,6 +18,7 @@ using Wino.Core.Integration.Json; using Wino.Messaging; using Wino.Messaging.Client.Connection; using Wino.Messaging.Enums; +using Wino.Messaging.Server; using Wino.Messaging.UI; namespace Wino.Core.UWP.Services @@ -253,6 +254,9 @@ namespace Wino.Core.UWP.Services case nameof(AccountFolderConfigurationUpdated): WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson)); break; + case nameof(CopyAuthURLRequested): + WeakReferenceMessenger.Default.Send(JsonSerializer.Deserialize(messageJson)); + break; default: throw new Exception("Invalid data type name passed to client."); } diff --git a/Wino.Core/Authenticators/GmailAuthenticator.cs b/Wino.Core/Authenticators/GmailAuthenticator.cs index faee8d43..9fe3aaa3 100644 --- a/Wino.Core/Authenticators/GmailAuthenticator.cs +++ b/Wino.Core/Authenticators/GmailAuthenticator.cs @@ -3,6 +3,7 @@ using System.Net.Http; using System.Text; using System.Text.Json.Nodes; using System.Threading.Tasks; +using CommunityToolkit.Mvvm.Messaging; using Wino.Core.Domain; using Wino.Core.Domain.Entities; using Wino.Core.Domain.Enums; @@ -11,6 +12,7 @@ using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Authentication; using Wino.Core.Domain.Models.Authorization; using Wino.Core.Services; +using Wino.Messaging.Server; namespace Wino.Core.Authenticators { @@ -24,6 +26,8 @@ namespace Wino.Core.Authenticators public override MailProviderType ProviderType => MailProviderType.Gmail; + public bool ProposeCopyAuthURL { get; set; } + private readonly INativeAppService _nativeAppService; public GmailAuthenticator(ITokenService tokenService, INativeAppService nativeAppService) : base(tokenService) @@ -121,6 +125,11 @@ namespace Wino.Core.Authenticators Uri responseRedirectUri = null; + if (ProposeCopyAuthURL) + { + WeakReferenceMessenger.Default.Send(new CopyAuthURLRequested(authorizationUri)); + } + try { responseRedirectUri = await _nativeAppService.GetAuthorizationResponseUriAsync(this, authorizationUri); diff --git a/Wino.Mail.ViewModels/AccountManagementViewModel.cs b/Wino.Mail.ViewModels/AccountManagementViewModel.cs index 78ee7f71..a402f259 100644 --- a/Wino.Mail.ViewModels/AccountManagementViewModel.cs +++ b/Wino.Mail.ViewModels/AccountManagementViewModel.cs @@ -196,7 +196,8 @@ namespace Wino.Mail.ViewModels var tokenInformationResponse = await _winoServerConnectionManager .GetResponseAsync(new AuthorizationRequested(accountCreationDialogResult.ProviderType, - createdAccount), accountCreationCancellationTokenSource.Token); + createdAccount, + createdAccount.ProviderType == MailProviderType.Gmail), accountCreationCancellationTokenSource.Token); if (creationDialog.State == AccountCreationDialogState.Canceled) throw new AccountSetupCanceledException(); diff --git a/Wino.Mail/Dialogs/AccountCreationDialog.xaml b/Wino.Mail/Dialogs/AccountCreationDialog.xaml index cb0220e7..351cf0ae 100644 --- a/Wino.Mail/Dialogs/AccountCreationDialog.xaml +++ b/Wino.Mail/Dialogs/AccountCreationDialog.xaml @@ -8,6 +8,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" x:Name="Root" + Closing="DialogClosing" CornerRadius="8" mc:Ignorable="d"> @@ -31,15 +32,56 @@ Text="{x:Bind domain:Translator.AccountCreationDialog_Initializing}" TextWrapping="Wrap" /> + +