🐛 Fix magic spell and email service

This commit is contained in:
2025-04-29 21:52:35 +08:00
parent 0ebeab672b
commit 35792efa9f
10 changed files with 56 additions and 38 deletions

View File

@ -1,5 +1,5 @@
@page "/auth/captcha"
@model DysonNetwork.Sphere.Pages.CheckpointPage
@model DysonNetwork.Sphere.Pages.Checkpoint.CheckpointPage
@{
Layout = null;
@ -73,6 +73,9 @@
defer
></script>
break;
case "hcaptcha":
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
break;
}
</head>
<body>
@ -95,6 +98,13 @@
data-callback="onSuccess"
></div>
break;
case "hcaptcha":
<div
class="h-captcha"
data-sitekey="@apiKey"
data-callback="onSuccess"
></div>
break;
default:
<p style="color: yellow;">Captcha provider not configured correctly.</p>
break;

View File

@ -1,13 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace DysonNetwork.Sphere.Pages;
namespace DysonNetwork.Sphere.Pages.Checkpoint;
public class CheckpointPage(IConfiguration configuration) : PageModel
{
[BindProperty] public IConfiguration Configuration { get; set; } = configuration;
public void OnGet()
public ActionResult OnGet()
{
return Page();
}
}

View File

@ -1,6 +1,6 @@
@page "/spells/{spellWord}"
@using DysonNetwork.Sphere.Account
@model DysonNetwork.Sphere.Pages.MagicSpellPage
@model DysonNetwork.Sphere.Pages.Spell.MagicSpellPage
@{
Layout = null;
@ -8,8 +8,6 @@
var spell = ViewData["Spell"] as MagicSpell;
}
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
@ -57,10 +55,6 @@
margin-bottom: 5px;
opacity: 0.8;
}
.g-recaptcha {
display: inline-block; /* Adjust as needed */
}
</style>
</head>
<body>

View File

@ -4,21 +4,27 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using NodaTime;
namespace DysonNetwork.Sphere.Pages;
namespace DysonNetwork.Sphere.Pages.Spell;
public class MagicSpellPage(AppDatabase db, MagicSpellService spells) : PageModel
{
public async Task<ActionResult> OnGet(string spellWord)
public async Task<IActionResult> OnGetAsync(string spellWord)
{
spellWord = Uri.UnescapeDataString(spellWord);
var now = SystemClock.Instance.GetCurrentInstant();
var spell = await db.MagicSpells
.Where(e => e.Spell == spellWord)
.Where(e => e.ExpiresAt == null || now >= e.ExpiresAt)
.Where(e => e.ExpiresAt == null || now < e.ExpiresAt)
.Where(e => e.AffectedAt == null || now >= e.AffectedAt)
.FirstOrDefaultAsync();
ViewData["Spell"] = spell;
if (spell is not null)
{
await spells.ApplyMagicSpell(spell);
}
return Page();
}
}