using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using PlotLine.Services; using PlotLine.ViewModels; namespace PlotLine.Controllers; [AllowAnonymous] [Route("word-companion")] public sealed class WordCompanionHostController(ICurrentUserService currentUser, IAuthorizationService authorization) : Controller { [HttpGet("")] public async Task Index() { var isAdmin = currentUser.IsAuthenticated && (await authorization.AuthorizeAsync(User, "AdminOnly")).Succeeded; return View(new WordCompanionHostViewModel { IsAuthenticated = currentUser.IsAuthenticated, IsAdmin = isAdmin, DisplayName = currentUser.DisplayName, LoginUrl = Url.Action("Login", "Account", new { returnUrl = "/word-companion" }) ?? "/Account/Login?returnUrl=%2Fword-companion" }); } }