From 98030194852f6251ad089311c7b824814df8ad58 Mon Sep 17 00:00:00 2001 From: Richasy Date: Thu, 20 Oct 2022 16:10:02 +0800 Subject: [PATCH 1/4] Remove local provider --- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 12672ee..077fd3b 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; @@ -33,7 +34,7 @@ public class WindowsProvider : BaseProvider private const string SettingsKeyProviderId = "WindowsProvider_ProviderId"; private const string SettingsKeyProviderAuthority = "WindowsProvider_Authority"; - private static readonly SemaphoreSlim SemaphoreSlim = new (1); + private static readonly SemaphoreSlim SemaphoreSlim = new(1); // Default/minimal scopes for authentication, if none are provided. private static readonly string[] DefaultScopes = { "User.Read" }; @@ -572,13 +573,6 @@ private async Task> GetWebAccountProvidersAsync() await FindAndAddProviderAsync(MicrosoftProviderId, AadAuthority); } - // Local - if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Any || - _webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) - { - await FindAndAddProviderAsync(LocalProviderId); - } - return providers; async Task FindAndAddProviderAsync( From fd99dfc7929aa117ead01a831fb95ba1e776f1aa Mon Sep 17 00:00:00 2001 From: Richasy Date: Thu, 20 Oct 2022 16:41:25 +0800 Subject: [PATCH 2/4] Update code --- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 077fd3b..51b1af7 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; @@ -34,7 +33,7 @@ public class WindowsProvider : BaseProvider private const string SettingsKeyProviderId = "WindowsProvider_ProviderId"; private const string SettingsKeyProviderAuthority = "WindowsProvider_Authority"; - private static readonly SemaphoreSlim SemaphoreSlim = new(1); + private static readonly SemaphoreSlim SemaphoreSlim = new (1); // Default/minimal scopes for authentication, if none are provided. private static readonly string[] DefaultScopes = { "User.Read" }; @@ -503,7 +502,6 @@ async void OnAccountCommandsRequested(AccountsSettingsPane sender, AccountsSetti } } } - catch (Exception ex) { webAccountProviderTaskCompletionSource.SetException(ex); } @@ -573,6 +571,11 @@ private async Task> GetWebAccountProvidersAsync() await FindAndAddProviderAsync(MicrosoftProviderId, AadAuthority); } + if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) + { + await FindAndAddProviderAsync(LocalProviderId); + } + return providers; async Task FindAndAddProviderAsync( From 00bf0792b17550e75bd36b1b5fa454a34b99fc06 Mon Sep 17 00:00:00 2001 From: Richasy Date: Thu, 20 Oct 2022 16:42:13 +0800 Subject: [PATCH 3/4] Update --- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 51b1af7..1955735 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -502,6 +502,7 @@ async void OnAccountCommandsRequested(AccountsSettingsPane sender, AccountsSetti } } } + catch (Exception ex) { webAccountProviderTaskCompletionSource.SetException(ex); } @@ -571,7 +572,7 @@ private async Task> GetWebAccountProvidersAsync() await FindAndAddProviderAsync(MicrosoftProviderId, AadAuthority); } - if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) + if(_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) { await FindAndAddProviderAsync(LocalProviderId); } From e48aecef239fcb6d432357b32d8a8b96eaed7dfb Mon Sep 17 00:00:00 2001 From: Richasy Date: Thu, 20 Oct 2022 16:42:40 +0800 Subject: [PATCH 4/4] Code style change --- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 1955735..a918efc 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -572,7 +572,7 @@ private async Task> GetWebAccountProvidersAsync() await FindAndAddProviderAsync(MicrosoftProviderId, AadAuthority); } - if(_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) + if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local) { await FindAndAddProviderAsync(LocalProviderId); }