Phase 4G AuthService Secure Controllers

This commit is contained in:
Nick Beckley 2026-06-06 20:36:54 +01:00
parent b3a3c045dc
commit 621d138571
30 changed files with 116 additions and 24 deletions

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class AcceptanceController(IAcceptanceService acceptance) : Controller
{
public async Task<IActionResult> Phase1(int? projectId)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class AnalyticsController(IAnalyticsService analytics) : Controller
{
public async Task<IActionResult> Index(

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ArchivesController(IArchiveService archives) : Controller
{
public async Task<IActionResult> Index(int? projectId, string? entityType)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class BooksController(IBookService books) : Controller
{
public async Task<IActionResult> Details(int id)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ChaptersController(IChapterService chapters) : Controller
{
public async Task<IActionResult> Details(int id)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class CharactersController(ICharacterService characters) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class DynamicsController(IDynamicsService dynamics) : Controller
{
public async Task<IActionResult> Story(int projectId)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ExportsController(IExportService exports, IProjectExportService projectExports, ILogger<ExportsController> logger) : Controller
{
public async Task<IActionResult> StoryBible(int projectId, string format = "html") =>

View File

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Route("Help")]
[Authorize]
public sealed class HelpController(IHelpService help, IHelpMarkdownRenderer markdown) : Controller
{
[HttpGet("")]

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class HelpDiagnosticsController(IHelpService help) : Controller
{
public IActionResult Index()

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class HelpDrawerController(
IHelpService help,
IHelpMarkdownRenderer markdown,

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Models;
@ -6,6 +7,7 @@ using System.Diagnostics;
namespace PlotLine.Controllers
{
[AllowAnonymous]
public class HomeController : Controller
{
public IActionResult Index()

View File

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
using System.Text;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ImportsController(IImportService imports) : Controller
{
public IActionResult Index() => View(new ImportIndexViewModel

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class LocationsController(ILocationService locations) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class PlotLinesController(IPlotService plots) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class PlotThreadsController(IPlotService plots) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ProjectMetricsController(ISceneMetricTypeService metrics) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ProjectRestorePointsController(
IProjectRestorePointService restorePoints,
IProjectRestoreService projectRestore,

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ProjectsController(IProjectService projects) : Controller
{
public async Task<IActionResult> Index() => View(await projects.ListAsync());

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class RelationshipMapController(IRelationshipMapService relationshipMap) : Controller
{
public async Task<IActionResult> Index(int projectId, int? bookId, int? chapterId, int? sceneId, int? focusCharacterId, bool showFullNetwork = false)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ScenariosController(IScenarioService scenarios) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class ScenesController(
ISceneService scenes,
IPlotService plots,

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class StoryAssetsController(IAssetService assets) : Controller
{
public async Task<IActionResult> Index(int projectId)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class StoryBibleController(IStoryBibleService storyBible) : Controller
{
public async Task<IActionResult> Index(int projectId, string? q)

View File

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Models;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class TimelineController(ITimelineService timeline) : Controller
{
public async Task<IActionResult> Index([FromQuery] TimelineFilterViewModel filter)

View File

@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
namespace PlotLine.Controllers;
[Authorize]
public sealed class WarningsController(IContinuityValidationService validation) : Controller
{
public async Task<IActionResult> Index(

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using PlotLine.Services;
using PlotLine.ViewModels;
namespace PlotLine.Controllers;
[Authorize]
public sealed class WriterController(IWriterWorkspaceService writerWorkspace) : Controller
{
public async Task<IActionResult> Index(int? projectId)

View File

@ -152,7 +152,7 @@ public class Program
app.MapStaticAssets();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Projects}/{action=Index}/{id?}")
pattern: "{controller=Home}/{action=Index}/{id?}")
.WithStaticAssets();
app.Run();

View File

@ -1,8 +1,43 @@
@{
ViewData["Title"] = "Home Page";
@{
ViewData["Title"] = "PlotWeaver Studio";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<section class="page-heading">
<div>
<p class="eyebrow">Story planning workspace</p>
<h1>PlotWeaver Studio</h1>
<p class="lead-text">
A story planning workspace for writers who need to track plots, scenes, characters, clues, threads, and continuity without losing their minds.
</p>
</div>
<div class="button-row">
@if (User.Identity?.IsAuthenticated == true)
{
<a class="btn btn-primary" asp-controller="Projects" asp-action="Index">Go to Projects</a>
}
else
{
<a class="btn btn-primary" asp-controller="Account" asp-action="Login">Sign in</a>
<a class="btn btn-outline-primary" asp-controller="Account" asp-action="Register">Create account</a>
}
</div>
</section>
<section class="content-grid">
<article class="plain-card">
<h2>Plan books, chapters, and scenes</h2>
<p>Shape a novel, a series, or a messy first draft into a structure you can actually see and revise.</p>
</article>
<article class="plain-card">
<h2>Track characters and relationships</h2>
<p>Follow appearances, arcs, knowledge, relationships, locations, and the changing emotional pressure of the story.</p>
</article>
<article class="plain-card">
<h2>Follow plot lines and clues</h2>
<p>Keep promises, reveals, unresolved threads, objects, and story assets visible from setup to payoff.</p>
</article>
<article class="plain-card">
<h2>Review story health</h2>
<p>Use timelines, metrics, warnings, and continuity checks to find problems before they spread through the manuscript.</p>
</article>
</section>

View File

@ -27,13 +27,18 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm border-bottom plotline-nav mb-3">
<div class="container-fluid">
<a class="navbar-brand fw-semibold" asp-area="" asp-controller="Projects" asp-action="Index">PlotWeaver Studio</a>
<a class="navbar-brand fw-semibold" asp-area="" asp-controller="Home" asp-action="Index">PlotWeaver Studio</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
@if (User.Identity?.IsAuthenticated == true)
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Projects" asp-action="Index">Projects</a>
</li>
@ -49,9 +54,7 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Help" asp-action="Index">Help</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">About</a>
</li>
}
</ul>
<div class="d-flex align-items-center gap-2 flex-wrap">
@if (User.Identity?.IsAuthenticated == true)