diff --git a/DisCatSharp.Extensions.SimpleMusicCommands/ExtensionMethods.cs b/DisCatSharp.Extensions.SimpleMusicCommands/ExtensionMethods.cs
index 93c1dd8..0e48c00 100644
--- a/DisCatSharp.Extensions.SimpleMusicCommands/ExtensionMethods.cs
+++ b/DisCatSharp.Extensions.SimpleMusicCommands/ExtensionMethods.cs
@@ -31,16 +31,16 @@
namespace DisCatSharp.Extensions.SimpleMusicCommands;
///
-/// Defines various extensions specific to SimpleMusicCommandsExtension.
+/// Defines various extensions specific to SimpleMusicCommandsExtension.
///
public static class ExtensionMethods
{
///
- /// Enables SimpleMusicCommandsExtension module on this .
+ /// Enables SimpleMusicCommandsExtension module on this .
///
/// Client to enable SimpleMusicCommandsExtension for.
/// Lavalink configuration to use.
- /// Created .
+ /// Created .
public static SimpleMusicCommandsExtension UseSimpleMusicCommands(this DiscordClient client, LavalinkConfiguration? cfg = null)
{
if (client.GetExtension() != null)
@@ -55,11 +55,11 @@ public static SimpleMusicCommandsExtension UseSimpleMusicCommands(this DiscordCl
}
///
- /// Enables SimpleMusicCommandsExtension module on all shards in this .
+ /// Enables SimpleMusicCommandsExtension module on all shards in this .
///
/// Client to enable SimpleMusicCommandsExtension for.
/// Lavalink configuration to use.
- /// A dictionary of created , indexed by shard id.
+ /// A dictionary of created , indexed by shard id.
public static async Task> UseSimpleMusicCommandsAsync(this DiscordShardedClient client, LavalinkConfiguration? cfg = null)
{
var modules = new Dictionary();
@@ -77,7 +77,7 @@ public static async Task>
}
///
- /// Gets the active SimpleMusicCommandsExtension module for this client.
+ /// Gets the active SimpleMusicCommandsExtension module for this client.
///
/// Client to get SimpleMusicCommandsExtension module from.
/// The module, or null if not activated.
@@ -85,7 +85,7 @@ public static async Task>
=> client.GetExtension();
///
- /// Gets the active SimpleMusicCommandsExtension modules for all shards in this client.
+ /// Gets the active SimpleMusicCommandsExtension modules for all shards in this client.
///
/// Client to get SimpleMusicCommandsExtension instances from.
/// A dictionary of the modules, indexed by shard id.
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Entities/TwoFactorResponse.cs b/DisCatSharp.Extensions.TwoFactorCommands/Entities/TwoFactorResponse.cs
index 5b38088..7aed291 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Entities/TwoFactorResponse.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Entities/TwoFactorResponse.cs
@@ -20,38 +20,32 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-using DisCatSharp.Entities;
using DisCatSharp.EventArgs;
using DisCatSharp.Extensions.TwoFactorCommands.Enums;
namespace DisCatSharp.Extensions.TwoFactorCommands.Entities;
///
-/// The response given upon attempted two factor authentication.
+/// The response given upon attempted two factor authentication.
///
public class TwoFactorResponse
{
+ internal TwoFactorResponse()
+ { }
+
///
- /// The modal response . Null if is or .
+ /// The modal response . Null if is
+ /// or .
///
public ComponentInteractionCreateEventArgs ComponentInteraction { get; internal set; } = null;
///
- /// The this interaction took place with.
+ /// The this interaction took place with.
///
public DiscordClient Client { get; internal set; } = null;
///
- /// The of the two factor authentication.
+ /// The of the two factor authentication.
///
public TwoFactorResult Result { get; internal set; } = TwoFactorResult.TimedOut;
-
- internal TwoFactorResponse()
- { }
}
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Enums/TwoFactorResult.cs b/DisCatSharp.Extensions.TwoFactorCommands/Enums/TwoFactorResult.cs
index a082f9a..b8ffcf5 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Enums/TwoFactorResult.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Enums/TwoFactorResult.cs
@@ -23,32 +23,32 @@
namespace DisCatSharp.Extensions.TwoFactorCommands.Enums;
///
-/// Represents two factor responses.
+/// Represents two factor responses.
///
-public enum TwoFactorResult : int
+public enum TwoFactorResult
{
///
- /// Code is invalid.
+ /// Code is invalid.
///
InvalidCode = 1,
///
- /// Code is valid.
+ /// Code is valid.
///
ValidCode = 2,
///
- /// User is not enrolled.
+ /// User is not enrolled.
///
NotEnrolled = 3,
///
- /// Two factor input timed out.
+ /// Two factor input timed out.
///
TimedOut = 4,
///
- /// This function is not implemented.
+ /// This function is not implemented.
///
NotImplemented = int.MaxValue
}
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/ExtensionMethods.cs b/DisCatSharp.Extensions.TwoFactorCommands/ExtensionMethods.cs
index 10181ef..a9c7849 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/ExtensionMethods.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/ExtensionMethods.cs
@@ -31,16 +31,16 @@
namespace DisCatSharp.Extensions.TwoFactorCommands;
///
-/// Defines various extensions specific to TwoFactor.
+/// Defines various extensions specific to TwoFactor.
///
public static class ExtensionMethods
{
///
- /// Enables TwoFactor module on this .
+ /// Enables TwoFactor module on this .
///
/// Client to enable TwoFactor for.
/// TwoFactor configuration to use.
- /// Created .
+ /// Created .
public static TwoFactorExtension UseTwoFactor(this DiscordClient client, TwoFactorConfiguration? cfg = null)
{
if (client.GetExtension() != null)
@@ -55,11 +55,11 @@ public static TwoFactorExtension UseTwoFactor(this DiscordClient client, TwoFact
}
///
- /// Enables TwoFactor module on all shards in this .
+ /// Enables TwoFactor module on all shards in this .
///
/// Client to enable TwoFactor for.
/// TwoFactor configuration to use.
- /// A dictionary of created , indexed by shard id.
+ /// A dictionary of created , indexed by shard id.
public static async Task> UseTwoFactorAsync(this DiscordShardedClient client, TwoFactorConfiguration? cfg = null)
{
var modules = new Dictionary();
@@ -77,7 +77,7 @@ public static async Task> UseTwoFac
}
///
- /// Gets the active TwoFactor module for this client.
+ /// Gets the active TwoFactor module for this client.
///
/// Client to get TwoFactor module from.
/// The module, or null if not activated.
@@ -85,7 +85,7 @@ public static async Task> UseTwoFac
=> client.GetExtension();
///
- /// Gets the active TwoFactor modules for all shards in this client.
+ /// Gets the active TwoFactor modules for all shards in this client.
///
/// Client to get TwoFactor instances from.
/// A dictionary of the modules, indexed by shard id.
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/ApplicationCommandRequireEnrolledTwoFactorAttribute.cs b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/ApplicationCommandRequireEnrolledTwoFactorAttribute.cs
index 4abc190..41c2953 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/ApplicationCommandRequireEnrolledTwoFactorAttribute.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/ApplicationCommandRequireEnrolledTwoFactorAttribute.cs
@@ -29,19 +29,19 @@
namespace DisCatSharp.ApplicationCommands.Attributes;
///
-/// Defines that this application command can only be executed if the user is enrolled in two factor auth.
+/// Defines that this application command can only be executed if the user is enrolled in two factor auth.
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = false)]
public sealed class ApplicationCommandRequireEnrolledTwoFactorAttribute : ApplicationCommandCheckBaseAttribute
{
///
- /// Defines that this application command can only be executed if the user is enrolled in two factor auth.
+ /// Defines that this application command can only be executed if the user is enrolled in two factor auth.
///
public ApplicationCommandRequireEnrolledTwoFactorAttribute()
{ }
///
- /// Runs checks.
+ /// Runs checks.
///
public override Task ExecuteChecksAsync(BaseContext ctx)
=> Task.FromResult(ctx.Client.GetTwoFactor().IsEnrolled(ctx.User.Id));
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/TwoFactorApplicationCommandExtension.cs b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/TwoFactorApplicationCommandExtension.cs
index 38eca6c..80265b7 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/TwoFactorApplicationCommandExtension.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/ApplicationCommands/TwoFactorApplicationCommandExtension.cs
@@ -27,8 +27,8 @@
using DisCatSharp.Entities;
using DisCatSharp.Enums;
using DisCatSharp.EventArgs;
-using DisCatSharp.Extensions.TwoFactorCommands.Enums;
using DisCatSharp.Extensions.TwoFactorCommands.Entities;
+using DisCatSharp.Extensions.TwoFactorCommands.Enums;
using DisCatSharp.Interactivity.Extensions;
namespace DisCatSharp.Extensions.TwoFactorCommands.ApplicationCommands;
@@ -36,12 +36,12 @@ namespace DisCatSharp.Extensions.TwoFactorCommands.ApplicationCommands;
public static class TwoFactorApplicationCommandExtension
{
///
- /// Asks the user via modal input for the two factor code.
- /// This uses DisCatSharp.Interactivity.
- /// To be used as first action for application commands.
+ /// Asks the user via modal input for the two factor code.
+ /// This uses DisCatSharp.Interactivity.
+ /// To be used as first action for application commands.
///
/// The base context.
- /// A .
+ /// A .
public static async Task RequestTwoFactorAsync(this BaseContext ctx)
{
var ext = ctx.Client.GetTwoFactor();
@@ -62,7 +62,7 @@ public static async Task RequestTwoFactorAsync(this BaseConte
builder.AddTextComponent(new(TextComponentStyle.Small, "code", "Code", "123456", ext.Configuration.Digits, ext.Configuration.Digits));
await ctx.CreateModalResponseAsync(builder);
- var response = new TwoFactorResponse()
+ var response = new TwoFactorResponse
{
Client = ctx.Client
};
@@ -99,13 +99,13 @@ public static async Task RequestTwoFactorAsync(this BaseConte
}
///
- /// Asks the user via modal input for the two factor code.
- /// This uses DisCatSharp.Interactivity.
- /// To be used as first action for button.
+ /// Asks the user via modal input for the two factor code.
+ /// This uses DisCatSharp.Interactivity.
+ /// To be used as first action for button.
///
/// The interaction context.
/// The discord client to use.
- /// A .
+ /// A .
public static async Task RequestTwoFactorAsync(this ComponentInteractionCreateEventArgs evt, DiscordClient client)
{
var ext = client.GetTwoFactor();
@@ -126,7 +126,7 @@ public static async Task RequestTwoFactorAsync(this Component
builder.AddTextComponent(new(TextComponentStyle.Small, "code", "Code", "123456", ext.Configuration.Digits, ext.Configuration.Digits));
await evt.Interaction.CreateInteractionModalResponseAsync(builder);
- var response = new TwoFactorResponse()
+ var response = new TwoFactorResponse
{
Client = client
};
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/CommandRequireEnrolledTwoFactorAttribute.cs b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/CommandRequireEnrolledTwoFactorAttribute.cs
index 45821f3..9ec3969 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/CommandRequireEnrolledTwoFactorAttribute.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/CommandRequireEnrolledTwoFactorAttribute.cs
@@ -29,19 +29,19 @@
namespace DisCatSharp.CommandsNext.Attributes;
///
-/// Defines that this command can only be executed if the user is enrolled in two factor auth.
+/// Defines that this command can only be executed if the user is enrolled in two factor auth.
///
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = false), Experimental("No support for this yet")]
public sealed class CommandRequireEnrolledTwoFactorAttribute : CheckBaseAttribute
{
///
- /// Defines that this command can only be executed if the user is enrolled in two factor auth.
+ /// Defines that this command can only be executed if the user is enrolled in two factor auth.
///
public CommandRequireEnrolledTwoFactorAttribute()
{ }
///
- /// Runs checks.
+ /// Runs checks.
///
public override Task ExecuteCheckAsync(CommandContext ctx, bool help)
=> Task.FromResult(ctx.Client.GetTwoFactor().IsEnrolled(ctx.User.Id));
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/TwoFactorCommandsNextExtension.cs b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/TwoFactorCommandsNextExtension.cs
index a9c7d0b..ccb33b2 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/TwoFactorCommandsNextExtension.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/Extensions/CommandsNext/TwoFactorCommandsNextExtension.cs
@@ -24,8 +24,8 @@
using DisCatSharp.Attributes;
using DisCatSharp.CommandsNext;
-using DisCatSharp.Extensions.TwoFactorCommands.Enums;
using DisCatSharp.Extensions.TwoFactorCommands.Entities;
+using DisCatSharp.Extensions.TwoFactorCommands.Enums;
namespace DisCatSharp.Extensions.TwoFactorCommands.CommandsNext;
@@ -33,16 +33,18 @@ public static class TwoFactorCommandsNextExtension
{
// TODO: Implement
///
- /// Asks the user via private for the two factor code.
- /// This uses DisCatSharp.Interactivity.
- /// To be used for commands next.
- /// Not implemented yet. Returns .
+ /// Asks the user via private for the two factor code.
+ /// This uses DisCatSharp.Interactivity.
+ /// To be used for commands next.
+ ///
+ /// Not implemented yet. Returns .
+ ///
///
/// The command context.
- /// A .
+ /// A .
[Experimental("No support for this yet. Not implemented")]
public static async Task RequestTwoFactorAsync(CommandContext ctx)
- => await Task.FromResult(new TwoFactorResponse()
+ => await Task.FromResult(new TwoFactorResponse
{
Result = TwoFactorResult.NotImplemented
});
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorConfiguration.cs b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorConfiguration.cs
index c39258a..9c6c490 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorConfiguration.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorConfiguration.cs
@@ -29,129 +29,135 @@
namespace DisCatSharp.Extensions.TwoFactorCommands;
///
-/// Represents a configuration for .
+/// Represents a configuration for .
///
public sealed class TwoFactorConfiguration
{
///
- /// Sets the service provider for this TwoFactor instance.
- /// Objects in this provider are used when instantiating command modules. This allows passing data around without resorting to static members.
- /// Defaults to an empty service provider.
+ /// Creates a new instance of .
///
- public IServiceProvider ServiceProvider { internal get; set; } = new ServiceCollection().BuildServiceProvider(true);
+ [ActivatorUtilitiesConstructor]
+ public TwoFactorConfiguration()
+ { }
///
- /// Sets the length of digits for the 2fa code. Defaults to 6.
+ /// Initializes a new instance of the class.
///
- public int Digits { internal get; set; } = 6;
+ /// The service provider.
+ [ActivatorUtilitiesConstructor]
+ public TwoFactorConfiguration(IServiceProvider provider)
+ {
+ this.ServiceProvider = provider;
+ }
///
- /// Sets the period in seconds how long a code is valid. Defaults to 30 seconds..
+ /// Creates a new instance of , copying the properties of another configuration.
///
- public int Period { internal get; set; } = 30;
+ /// Configuration the properties of which are to be copied.
+ public TwoFactorConfiguration(TwoFactorConfiguration other)
+ {
+ this.Digits = other.Digits;
+ this.Period = other.Period;
+ this.Algorithm = other.Algorithm;
+ this.Issuer = other.Issuer;
+ this.ResponseConfiguration = other.ResponseConfiguration;
+ }
///
- /// Sets the algorithm. Defaults to .
+ /// Sets the service provider for this TwoFactor instance.
+ ///
+ /// Objects in this provider are used when instantiating command modules. This allows passing data around without
+ /// resorting to static members.
+ ///
+ /// Defaults to an empty service provider.
///
- public Algorithm Algorithm { internal get; set; } = Algorithm.SHA1;
+ public IServiceProvider ServiceProvider { internal get; set; } = new ServiceCollection().BuildServiceProvider(true);
///
- /// Sets the issuer.
- /// Defaults to aitsys.dev to show the DisCatSharp logo.
+ /// Sets the length of digits for the 2fa code. Defaults to 6.
///
- public string Issuer { internal get; set; } = "aitsys.dev";
+ public int Digits { internal get; set; } = 6;
///
- /// Sets the database path. Defaults to ./twofactor.sqlite.
+ /// Sets the period in seconds how long a code is valid. Defaults to 30 seconds..
///
- public string DatabasePath { internal get; set; } = "./twofactor.sqlite";
+ public int Period { internal get; set; } = 30;
///
- /// Sets how long user have to enter the 2fa code. Defaults to 30 seconds.
+ /// Sets the algorithm. Defaults to .
///
- public int TwoFactorTimeout { internal get; set; } = 30;
+ public Algorithm Algorithm { internal get; set; } = Algorithm.SHA1;
///
- /// Sets overrides for default messages facing the user.
+ /// Sets the issuer.
+ /// Defaults to aitsys.dev to show the DisCatSharp logo.
///
- public TwoFactorResponseConfiguration ResponseConfiguration { internal get; set; } = new();
+ public string Issuer { internal get; set; } = "aitsys.dev";
///
- /// Creates a new instance of .
+ /// Sets the database path. Defaults to ./twofactor.sqlite.
///
- [ActivatorUtilitiesConstructor]
- public TwoFactorConfiguration()
- { }
+ public string DatabasePath { internal get; set; } = "./twofactor.sqlite";
///
- /// Initializes a new instance of the class.
+ /// Sets how long user have to enter the 2fa code. Defaults to 30 seconds.
///
- /// The service provider.
- [ActivatorUtilitiesConstructor]
- public TwoFactorConfiguration(IServiceProvider provider)
- {
- this.ServiceProvider = provider;
- }
+ public int TwoFactorTimeout { internal get; set; } = 30;
///
- /// Creates a new instance of , copying the properties of another configuration.
+ /// Sets overrides for default messages facing the user.
///
- /// Configuration the properties of which are to be copied.
- public TwoFactorConfiguration(TwoFactorConfiguration other)
- {
- this.Digits = other.Digits;
- this.Period = other.Period;
- this.Algorithm = other.Algorithm;
- this.Issuer = other.Issuer;
- this.ResponseConfiguration = other.ResponseConfiguration;
- }
+ public TwoFactorResponseConfiguration ResponseConfiguration { internal get; set; } = new();
}
///
-/// Represents a message configuration for .
+/// Represents a message configuration for .
///
public sealed class TwoFactorResponseConfiguration
{
///
- /// Whether to show a response after entering a two factor code. If set to false, you'll need to respond to the modal interaction yourself.
- /// Defaults to: true
+ /// Creates a new instance of .
+ ///
+ [ActivatorUtilitiesConstructor]
+ public TwoFactorResponseConfiguration()
+ { }
+
+ ///
+ ///
+ /// Whether to show a response after entering a two factor code. If set to false, you'll need to respond to the
+ /// modal interaction yourself.
+ ///
+ /// Defaults to: true
///
public bool ShowResponse { internal get; set; } = true;
///
- /// Sets the message when an correct two factor auth code was entered.
- /// Defaults to: Code valid!
+ /// Sets the message when an correct two factor auth code was entered.
+ /// Defaults to: Code valid!
///
public string AuthenticationSuccessMessage { internal get; set; } = "Code valid!";
///
- /// Sets the message when an incorrect two factor auth code was entered.
- /// Defaults to: Code invalid..
+ /// Sets the message when an incorrect two factor auth code was entered.
+ /// Defaults to: Code invalid..
///
public string AuthenticationFailureMessage { internal get; set; } = "Code invalid..";
///
- /// Sets the message when an user is not yet enrolled into two factor auth.
- /// Defaults to: You are not enrolled in two factor.
+ /// Sets the message when an user is not yet enrolled into two factor auth.
+ /// Defaults to: You are not enrolled in two factor.
///
public string AuthenticationNotEnrolledMessage { internal get; set; } = "You are not enrolled in two factor.";
///
- /// Sets the modal title for two factor auth requests.
- /// Defaults to: Enter 2FA Code
+ /// Sets the modal title for two factor auth requests.
+ /// Defaults to: Enter 2FA Code
///
public string AuthenticationModalRequestTitle { internal get; set; } = "Enter 2FA Code";
///
- /// Sets the account prefix used within the authenticator upon registration.
- /// Defaults to: DisCatSharp Auth
+ /// Sets the account prefix used within the authenticator upon registration.
+ /// Defaults to: DisCatSharp Auth
///
public string AuthenticatorAccountPrefix { internal get; set; } = "DisCatSharp Auth";
-
- ///
- /// Creates a new instance of .
- ///
- [ActivatorUtilitiesConstructor]
- public TwoFactorResponseConfiguration()
- { }
}
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtension.cs b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtension.cs
index 5ce1bd7..c854860 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtension.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtension.cs
@@ -23,7 +23,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Threading.Tasks;
using DatabaseWrapper.Core;
using DatabaseWrapper.Sqlite;
@@ -35,48 +34,27 @@
namespace DisCatSharp.Extensions.TwoFactorCommands;
///
-/// Represents a .
+/// Represents a .
///
public sealed class TwoFactorExtension : BaseExtension
{
///
- /// Gets the two factor configuration.
+ /// Gets the secret field name.
///
- internal TwoFactorConfiguration Configuration { get; private set; }
-
- ///
- /// Gets the database client.
- ///
- internal DatabaseClient DatabaseClient { get; private set; }
-
- ///
- /// Gets the tfa client.
- ///
- internal TwoFactorAuth TwoFactorClient { get; private set; }
+ private readonly string _secretField = "secret";
///
- /// Gets the table name.
+ /// Gets the table name.
///
private readonly string _tableName = "twofactor_mapper";
///
- /// Gets the user field name.
+ /// Gets the user field name.
///
private readonly string _userField = "user";
///
- /// Gets the secret field name.
- ///
- private readonly string _secretField = "secret";
-
- ///
- /// Gets the service provider this TwoFactor module was configured with.
- ///
- public IServiceProvider Services
- => this.Configuration.ServiceProvider;
-
- ///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The config.
internal TwoFactorExtension(TwoFactorConfiguration? configuration = null)
@@ -98,10 +76,31 @@ internal TwoFactorExtension(TwoFactorConfiguration? configuration = null)
}
///
- /// DO NOT USE THIS MANUALLY.
+ /// Gets the two factor configuration.
+ ///
+ internal TwoFactorConfiguration Configuration { get; }
+
+ ///
+ /// Gets the database client.
+ ///
+ internal DatabaseClient DatabaseClient { get; }
+
+ ///
+ /// Gets the tfa client.
+ ///
+ internal TwoFactorAuth TwoFactorClient { get; }
+
+ ///
+ /// Gets the service provider this TwoFactor module was configured with.
+ ///
+ public IServiceProvider Services
+ => this.Configuration.ServiceProvider;
+
+ ///
+ /// DO NOT USE THIS MANUALLY.
///
/// DO NOT USE THIS MANUALLY.
- ///
+ ///
protected internal override void Setup(DiscordClient client)
{
if (this.Client != null)
@@ -133,7 +132,7 @@ protected internal override void Setup(DiscordClient client)
}
///
- /// Checks whether the database has info about the given user id.
+ /// Checks whether the database has info about the given user id.
///
/// The user id to check.
///
@@ -141,14 +140,14 @@ private bool HasData(ulong user)
=> this.DatabaseClient.Exists(this._tableName, new(this._userField, OperatorEnum.Equals, user.ToString()));
///
- /// Gets the secret for the given user id from the database.
+ /// Gets the secret for the given user id from the database.
///
/// The user id to get data for.
private string GetSecretFor(ulong user)
=> this.DatabaseClient.Select(this._tableName, null, 1, null, new(this._userField, OperatorEnum.Equals, user.ToString())).Rows[0].ItemArray[1].ToString();
///
- /// Adds a secret for the given user id to the database.
+ /// Adds a secret for the given user id to the database.
///
/// The user id to add data for.
/// The secret to add.
@@ -163,14 +162,14 @@ private void AddSecretFor(ulong user, string secret)
}
///
- /// Removes a secret for the given user id in the database.
+ /// Removes a secret for the given user id in the database.
///
/// The user id to remove data for.
private void RemoveSecret(ulong user)
=> this.DatabaseClient.Delete(this._tableName, new(this._userField, OperatorEnum.Equals, user.ToString()));
///
- /// Checks whether the two factor auth code is valid for given user id.
+ /// Checks whether the two factor auth code is valid for given user id.
///
/// The user id entering the code.
/// The code to check.
@@ -179,7 +178,7 @@ internal bool IsValidCode(ulong user, string code)
=> this.HasData(user) && this.TwoFactorClient.VerifyCode(this.GetSecretFor(user), code);
///
- /// Checks whether given user id is enrolled in two factor auth.
+ /// Checks whether given user id is enrolled in two factor auth.
///
/// User id to check for enrollment.
/// Whether the user is enrolled.
@@ -187,7 +186,7 @@ internal bool IsEnrolled(ulong user)
=> this.HasData(user);
///
- /// Enrolls given user id with two factor auth.
+ /// Enrolls given user id with two factor auth.
///
/// User id to enroll.
/// Secret to use.
@@ -195,7 +194,7 @@ internal void EnrollUser(ulong user, string secret)
=> this.AddSecretFor(user, secret);
///
- /// Unenrolls given user id from two factor auth.
+ /// Unenrolls given user id from two factor auth.
///
/// User id to unenroll.
internal void DisenrollUser(ulong user)
diff --git a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtensionUtilities.cs b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtensionUtilities.cs
index 5ac6cb3..4a77813 100644
--- a/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtensionUtilities.cs
+++ b/DisCatSharp.Extensions.TwoFactorCommands/TwoFactorExtensionUtilities.cs
@@ -32,7 +32,7 @@ namespace DisCatSharp.Extensions.TwoFactorCommands;
public static class TwoFactorExtensionUtilities
{
///
- /// Checks two factor registration for the given user id.
+ /// Checks two factor registration for the given user id.
///
/// The discord client.
/// The user id to check.
@@ -41,7 +41,7 @@ public static bool CheckTwoFactorEnrollmentFor(this DiscordClient client, ulong
=> client.GetTwoFactor().IsEnrolled(user);
///
- /// Removes the two factor registration for the given user id.
+ /// Removes the two factor registration for the given user id.
///
/// The discord client.
/// The user id to check.
@@ -49,11 +49,14 @@ public static void DisenrollTwoFactor(this DiscordClient client, ulong user)
=> client.GetTwoFactor().DisenrollUser(user);
///
- /// Registers two factor for the given user.
+ /// Registers two factor for the given user.
///
/// The discord client.
/// The user to check.
- /// A where Secret is a string with the secret itself and QrCode a MemoryStream with the qr code image.
+ ///
+ /// A where Secret is a string with the
+ /// secret itself and QrCode a MemoryStream with the qr code image.
+ ///
public static (string Secret, MemoryStream QrCode) EnrollTwoFactor(this DiscordClient client, DiscordUser user)
{
var ext = client.GetTwoFactor();