aboutsummaryrefslogtreecommitdiff
path: root/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/VNLib.Plugins.Essentials.Accounts.Registration/src')
-rw-r--r--plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs58
-rw-r--r--plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj3
2 files changed, 31 insertions, 30 deletions
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs b/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs
index c1f8589..6a81e7e 100644
--- a/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs
+++ b/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/Endpoints/RegistrationEntpoint.cs
@@ -5,18 +5,18 @@
* Package: VNLib.Plugins.Essentials.Accounts.Registration
* File: RegistrationEntpoint.cs
*
-* RegistrationEntpoint.cs is part of VNLib.Plugins.Essentials.Accounts.Registration which is part of the larger
-* VNLib collection of libraries and utilities.
+* RegistrationEntpoint.cs is part of VNLib.Plugins.Essentials.Accounts.Registration
+* which is part of the larger VNLib collection of libraries and utilities.
*
-* VNLib.Plugins.Essentials.Accounts.Registration is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Affero General Public License as
-* published by the Free Software Foundation, either version 3 of the
-* License, or (at your option) any later version.
+* VNLib.Plugins.Essentials.Accounts.Registration is free software: you can
+* redistribute it and/or modify it under the terms of the GNU Affero General
+* Public License as published by the Free Software Foundation, either version
+* 3 of the License, or (at your option) any later version.
*
-* VNLib.Plugins.Essentials.Accounts.Registration is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Affero General Public License for more details.
+* VNLib.Plugins.Essentials.Accounts.Registration is distributed in the
+* hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+* PURPOSE. See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
@@ -29,6 +29,7 @@ using System.Text.Json;
using FluentValidation;
using Emails.Transactional.Client;
+using Emails.Transactional.Client.Plugins;
using Emails.Transactional.Client.Exceptions;
using VNLib.Hashing;
@@ -45,7 +46,6 @@ using VNLib.Plugins.Extensions.Loading.Sql;
using VNLib.Plugins.Extensions.Loading.Events;
using VNLib.Plugins.Extensions.Loading.Users;
using VNLib.Plugins.Extensions.Validation;
-using Emails.Transactional.Client.Extensions;
using VNLib.Plugins.Essentials.Accounts.Registration.TokenRevocation;
using static VNLib.Plugins.Essentials.Accounts.AccountUtil;
@@ -89,15 +89,16 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.Endpoints
RegJwtValdidator = GetJwtValidator();
Passwords = plugin.GetOrCreateSingleton<ManagedPasswordHashing>();
- Users = plugin.GetOrCreateSingleton<UserManager>();
- RevokedTokens = new(plugin.GetContextOptions());
+ Users = plugin.GetOrCreateSingleton<UserManager>();
Emails = plugin.GetOrCreateSingleton<TEmailConfig>();
+ RevokedTokens = new(plugin.GetContextOptions());
//Begin the async op to get the signature key from the vault
RegSignatureKey = plugin.GetSecretAsync("reg_sig_key")
.ToLazy(static sr => sr.GetJsonWebKey());
}
+
private static IValidator<string> GetJwtValidator()
{
InlineValidator<string> val = new();
@@ -111,7 +112,15 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.Endpoints
.IllegalCharacters();
return val;
}
-
+
+ //Schedule cleanup interval
+ [AsyncInterval(Minutes = 5)]
+ public async Task OnIntervalAsync(ILogProvider log, CancellationToken cancellationToken)
+ {
+ //Cleanup tokens
+ await RevokedTokens.CleanTableAsync(RegExpiresSec, cancellationToken);
+ }
+
protected override async ValueTask<VfReturnType> PostAsync(HttpEntity entity)
{
@@ -319,12 +328,13 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.Endpoints
{
//Get a new registration template
EmailTransactionRequest emailTemplate = Emails.GetTemplateRequest("Registration");
+
//Add the user's to address
- emailTemplate.AddToAddress(emailAddress);
- emailTemplate.AddVariable("username", emailAddress);
- //Set the security code variable string
- emailTemplate.AddVariable("reg_url", url);
- emailTemplate.AddVariable("date", current.ToString("f"));
+ emailTemplate.AddToAddress(emailAddress)
+ .AddVariable("username", emailAddress)
+ //Set the security code variable string
+ .AddVariable("reg_url", url)
+ .AddVariable("date", current.ToString("f"));
//Send the email
TransactionResult result = await Emails.SendEmailAsync(emailTemplate);
@@ -356,14 +366,6 @@ namespace VNLib.Plugins.Essentials.Accounts.Registration.Endpoints
Log.Error(ex);
}
}
-
-
- //Schedule cleanup interval 60 seconds
- [AsyncInterval(Minutes = 1)]
- public async Task OnIntervalAsync(ILogProvider log, CancellationToken cancellationToken)
- {
- //Cleanup tokens
- await RevokedTokens.CleanTableAsync(RegExpiresSec, cancellationToken);
- }
+
}
} \ No newline at end of file
diff --git a/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj b/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj
index ba91d90..d20457d 100644
--- a/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj
+++ b/plugins/VNLib.Plugins.Essentials.Accounts.Registration/src/VNLib.Plugins.Essentials.Accounts.Registration.csproj
@@ -34,12 +34,11 @@
<Deterministic>False</Deterministic>
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="FluentValidation" Version="11.6.0" />
+ <PackageReference Include="FluentValidation" Version="11.7.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\core\lib\Plugins.Essentials\src\VNLib.Plugins.Essentials.csproj" />
<ProjectReference Include="..\..\..\..\Emails.Transactional\lib\Emails.Transactional.Client\src\Emails.Transactional.Client.csproj" />
- <ProjectReference Include="..\..\..\..\Emails.Transactional\lib\Emails.Transactional.Extensions\src\Emails.Transactional.Client.Extensions.csproj" />
<ProjectReference Include="..\..\..\..\Extensions\lib\VNLib.Plugins.Extensions.Data\src\VNLib.Plugins.Extensions.Data.csproj" />
<ProjectReference Include="..\..\..\..\Extensions\lib\VNLib.Plugins.Extensions.Loading.Sql\src\VNLib.Plugins.Extensions.Loading.Sql.csproj" />
<ProjectReference Include="..\..\..\..\Extensions\lib\VNLib.Plugins.Extensions.Loading\src\VNLib.Plugins.Extensions.Loading.csproj" />