Exemplo n.º 1
0
        public static bool TryParseTwoFactorChannel(string text, out TwoFactorChannel channel)
        {
            if (!string.IsNullOrEmpty(text))
            {
                foreach (var pair in TwoFactorChannels)
                {
                    if (pair.Value.Equals(text))
                    {
                        channel = pair.Key;
                        return(true);
                    }
                }
            }

            channel = TwoFactorChannel.Other;
            return(false);
        }
Exemplo n.º 2
0
        private static string ChannelText(this TwoFactorChannel channel)
        {
            switch (channel)
            {
            case TwoFactorChannel.Authenticator: return("authenticator");

            case TwoFactorChannel.TextMessage: return("sms");

            case TwoFactorChannel.DuoSecurity: return("duo");

            case TwoFactorChannel.RSASecurID: return("rsa");

            case TwoFactorChannel.KeeperDNA: return("dna");

            case TwoFactorChannel.SecurityKey: return("key");

            default: return(channel.ToString().ToLowerInvariant());
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sends verification code
 /// </summary>
 /// <param name="channel"></param>
 /// <param name="code"></param>
 /// <returns>Awaitable task</returns>
 public Task SendCode(TwoFactorChannel channel, string code)
 {
     return(OnSendCode?.Invoke(channel, code));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets phone number for the channel
 /// </summary>
 /// <param name="channel">Two factor authentication channel</param>
 /// <returns>Phone number registered to the channel.</returns>
 public string GetPhoneNumber(TwoFactorChannel channel)
 {
     return(OnGetPhoneNumber?.Invoke(channel));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Gets flag if channel accepts verification codes
 /// </summary>
 /// <param name="channel">Two factor authentication channel</param>
 /// <returns><c>True</c> if the channel supports verification codes</returns>
 public bool IsCodeChannel(TwoFactorChannel channel)
 {
     return(OnIsCodeChannel?.Invoke(channel) ?? false);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Gets available push actions for the channel
 /// </summary>
 /// <param name="channel">Two factor authentication channel</param>
 /// <returns>List of available push actions</returns>
 public TwoFactorPushAction[] GetChannelPushActions(TwoFactorChannel channel)
 {
     return(OnGetChannelPushActions != null?OnGetChannelPushActions(channel) : new TwoFactorPushAction[]
     {
     });
 }
Exemplo n.º 7
0
 public static string GetTwoFactorChannelText(this TwoFactorChannel channel)
 {
     return(TwoFactorChannels.TryGetValue(channel, out var text) ? text : channel.ToString());
 }