using Htmx.ApiDemo; using Htmx.ApiDemo.Data; using Immediate.Apis.Shared; using Immediate.Handlers.Shared; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Htmx.ApiDemo.Templates; [Handler] [MapPost("/logout")] public static partial class PostLogoutHandler { // Empty command — [AsParameters] ensures form content-type is accepted // and antiforgery token in the form is validated by the middleware. public class Command; private static async ValueTask HandleAsync( [AsParameters] Command _, AuthService authService, IHttpContextAccessor httpContextAccessor, CancellationToken token) { await authService.SignOutAsync(); return new HtmxResult("/login"); } }