CodeLiturgy.Dashboard/CodeLiturgy.Views/Controllers/HomeController.cs

44 lines
1017 B
C#

using BlueWest.Data.Auth.Context.Users;
using Microsoft.AspNetCore.Mvc;
using CodeLiturgy.Views.Utils;
using Duende.IdentityServer.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Options;
using Controller = Microsoft.AspNetCore.Mvc.Controller;
namespace CodeLiturgy.Views.Controllers;
[System.Web.Mvc.Route("/")]
[System.Web.Mvc.Authorize]
public class HomeController : UserController
{
public HomeController(ApplicationUserManager userManager, ILogger<HomeController> logger) : base(userManager, logger)
{
_userManager = userManager;
_logger = logger;
}
public override void OnInitialization()
{
var menu = LayoutCache.Root.ChildrenToUrl();
SetHeaderMenu(menu);
}
[AllowAnonymous]
public async Task<IActionResult> Index()
{
await OnEveryAction();
if (!User.IsAuthenticated())
{
return Redirect("/auth/login");
}
return View();
}
}