✨ Magic spell for one time code
🗑️ Drop the usage of casbin ♻️ Refactor the permission service ♻️ Refactor the flow of creating an account 🧱 Email infra structure
This commit is contained in:
24
DysonNetwork.Sphere/Pages/MagicSpellPage.cshtml.cs
Normal file
24
DysonNetwork.Sphere/Pages/MagicSpellPage.cshtml.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using DysonNetwork.Sphere.Account;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Sphere.Pages;
|
||||
|
||||
public class MagicSpellPage(AppDatabase db, MagicSpellService spells) : PageModel
|
||||
{
|
||||
public async Task<ActionResult> OnGet(string 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.AffectedAt == null || now >= e.AffectedAt)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
ViewData["Spell"] = spell;
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user