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); }
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()); } }
/// <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)); }
/// <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)); }
/// <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); }
/// <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[] { }); }
public static string GetTwoFactorChannelText(this TwoFactorChannel channel) { return(TwoFactorChannels.TryGetValue(channel, out var text) ? text : channel.ToString()); }