Merge pull request #191 from Richasy/anran/removeNullProvider
Avoid adding empty providers
This commit is contained in:
Коммит
d985141a31
|
@ -562,24 +562,37 @@ namespace CommunityToolkit.Authentication
|
|||
if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Any ||
|
||||
_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Msa)
|
||||
{
|
||||
providers.Add(await WebAuthenticationCoreManager.FindAccountProviderAsync(MicrosoftProviderId, MicrosoftAccountAuthority));
|
||||
await FindAndAddProviderAsync(MicrosoftProviderId, MicrosoftAccountAuthority);
|
||||
}
|
||||
|
||||
// AAD
|
||||
if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Any ||
|
||||
_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Aad)
|
||||
{
|
||||
providers.Add(await WebAuthenticationCoreManager.FindAccountProviderAsync(MicrosoftProviderId, AadAuthority));
|
||||
await FindAndAddProviderAsync(MicrosoftProviderId, AadAuthority);
|
||||
}
|
||||
|
||||
// Local
|
||||
if (_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Any ||
|
||||
_webAccountProviderConfig.WebAccountProviderType == WebAccountProviderType.Local)
|
||||
{
|
||||
providers.Add(await WebAuthenticationCoreManager.FindAccountProviderAsync(LocalProviderId));
|
||||
await FindAndAddProviderAsync(LocalProviderId);
|
||||
}
|
||||
|
||||
return providers;
|
||||
|
||||
async Task FindAndAddProviderAsync(
|
||||
string webAccountProviderId,
|
||||
string authority = default)
|
||||
{
|
||||
var provider = string.IsNullOrEmpty(authority)
|
||||
? await WebAuthenticationCoreManager.FindAccountProviderAsync(webAccountProviderId)
|
||||
: await WebAuthenticationCoreManager.FindAccountProviderAsync(webAccountProviderId, authority);
|
||||
if (provider != null)
|
||||
{
|
||||
providers.Add(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче