Exemplo n.º 1
0
        public TwoFactorProviderType?GetDefaultTwoFactorProvider(bool u2fSupported)
        {
            if (TwoFactorProvidersData == null)
            {
                return(null);
            }
            if (SelectedTwoFactorProviderType != null &&
                TwoFactorProvidersData.ContainsKey(SelectedTwoFactorProviderType.Value))
            {
                return(SelectedTwoFactorProviderType.Value);
            }
            TwoFactorProviderType?providerType = null;
            var providerPriority = -1;

            foreach (var providerKvp in TwoFactorProvidersData)
            {
                if (TwoFactorProviders.ContainsKey(providerKvp.Key))
                {
                    var provider = TwoFactorProviders[providerKvp.Key];
                    if (provider.Priority > providerPriority)
                    {
                        if (providerKvp.Key == TwoFactorProviderType.U2f && !u2fSupported)
                        {
                            continue;
                        }
                        providerType     = providerKvp.Key;
                        providerPriority = provider.Priority;
                    }
                }
            }
            return(providerType);
        }
Exemplo n.º 2
0
 public virtual async Task <bool> VerifyTwoFactorTokenAsync(TUser user, string twoFactorProvider, string token)
 {
     ThrowIfDisposed();
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     if (!TwoFactorProviders.ContainsKey(twoFactorProvider))
     {
         throw new NotSupportedException("No TwoFactorProvider");
     }
     return(await TwoFactorProviders[twoFactorProvider].ValidateAsync(twoFactorProvider, token, this, user));
 }