Abstraction of authenticators. Reworked Gmail authentication.

This commit is contained in:
Burak Kaan Köse
2024-11-20 01:45:48 +01:00
parent 8367efa174
commit 7fad15524f
44 changed files with 354 additions and 605 deletions

View File

@@ -1,7 +1,5 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Nito.AsyncEx;
using Windows.ApplicationModel;
using Windows.Foundation.Metadata;
using Windows.Security.Authentication.Web;
@@ -11,8 +9,6 @@ using Windows.Storage;
using Windows.Storage.Streams;
using Windows.System;
using Windows.UI.Shell;
using Wino.Core.Domain;
using Wino.Core.Domain.Exceptions;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Authorization;
@@ -156,26 +152,6 @@ namespace Wino.Services
await taskbarManager.RequestPinCurrentAppAsync();
}
public async Task<Uri> GetAuthorizationResponseUriAsync(IAuthenticator authenticator,
string authorizationUri,
CancellationToken cancellationToken = default)
{
if (authorizationCompletedTaskSource != null)
{
authorizationCompletedTaskSource.TrySetException(new AuthenticationException(Translator.Exception_AuthenticationCanceled));
authorizationCompletedTaskSource = null;
}
authorizationCompletedTaskSource = new TaskCompletionSource<Uri>();
bool isLaunched = await Launcher.LaunchUriAsync(new Uri(authorizationUri)).AsTask(cancellationToken);
if (!isLaunched)
throw new WinoServerException("Failed to launch Google Authentication dialog.");
return await authorizationCompletedTaskSource.Task.WaitAsync(cancellationToken);
}
public void ContinueAuthorization(Uri authorizationResponseUri)
{
if (authorizationCompletedTaskSource != null)

View File

@@ -4,9 +4,9 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
xmlns:helpers="using:Wino.Helpers"
xmlns:coreControls="using:Wino.Core.UWP.Controls"
xmlns:domain="using:Wino.Core.Domain"
xmlns:helpers="using:Wino.Helpers"
xmlns:local="using:Wino.Core.UWP.Styles"
xmlns:menu="using:Wino.Core.MenuItems"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"