add local capjs widget

This commit is contained in:
2026-03-05 15:56:44 +01:00
parent 42b5732808
commit b23c7c805d
6 changed files with 36 additions and 5 deletions
+13 -3
View File
@@ -33,8 +33,18 @@ public class Mail : MailMessage
/// </summary>
public Mail For(MailOptions options)
{
To.Add(new MailAddress(options.To, options.ToName));
From = new MailAddress(options.From, options.FromName);
if (options.To.HasValue())
{
To.Add(new MailAddress(options.To, options.ToName));
}
if (options.From.HasValue())
{
From = new MailAddress(options.From, options.FromName);
}
if (options.ReplyTo.HasValue())
{
ReplyToList.Add(options.ReplyTo);
}
return this;
}
@@ -44,7 +54,7 @@ public class Mail : MailMessage
public string PlainText
{
get => Body;
set
set
{
Body = value;
IsBodyHtml = false;
+1 -1
View File
@@ -20,7 +20,7 @@ public class MailOptions
public string ReplyTo { get; set; }
public bool Debug { get; set; } = true;
public bool Debug { get; set; }
public string SenderEmail { get; set; }
File diff suppressed because one or more lines are too long
+2
View File
@@ -31,7 +31,9 @@ public class CaptchaTagHelper(IOptionsMonitor<CaptchaOptions> options) : TagHelp
output.Attributes.SetAttribute("data-cap-hidden-field-name", _options.HiddenFieldName);
string wasmFilePath =_options.Endpoint + "/cap.wasm";
string widgetFilePath =_options.Endpoint + "/cap.widget.js";
output.PreElement.AppendHtml($"<script>window.CAP_CUSTOM_WASM_URL = '{wasmFilePath}';</script>");
output.PreElement.AppendHtml($"<script type='module' src='{widgetFilePath}'></script>");
foreach ((string key, string value) in _options.Localization)
{
+18
View File
@@ -49,6 +49,24 @@ internal class ZeroSecurityModule : ZeroModule
await resource.CopyToAsync(context.Response.Body, context.RequestAborted);
}
});
endpoints.MapGet(endpointPrefix + "/cap.widget.js", async context =>
{
Assembly assembly = typeof(ZeroSecurityModule).GetTypeInfo().Assembly;
Stream resource = assembly.GetManifestResourceStream("zero.Resources.cap_min_0_1_41.js");
if (resource is null)
{
context.Response.StatusCode = StatusCodes.Status404NotFound;
return;
}
await using (resource)
{
context.Response.ContentType = "text/javascript";
await resource.CopyToAsync(context.Response.Body, context.RequestAborted);
}
});
});
StaticCaptchaService.Configure(serviceProvider);
}
+1 -1
View File
@@ -22,7 +22,7 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\cap_wasm_bg_0_0_6.wasm" />
<EmbeddedResource Include="Resources\**\*" />
</ItemGroup>
</Project>