Put most things behind administrator authorization. Update access denied page.

This commit is contained in:
Pat Hartl 2023-01-04 01:45:54 -06:00
parent bbdb1dcb7a
commit a0d7134af3
8 changed files with 24 additions and 9 deletions

View file

@ -1,10 +1,23 @@
@page @page
@model AccessDeniedModel @model AccessDeniedModel
@{ Layout = "/Views/Shared/_LayoutBasic.cshtml"; }
@{ @{
ViewData["Title"] = "Access denied"; ViewData["Title"] = "Access denied";
} }
<header> <div class="page page-center">
<h1 class="text-danger">@ViewData["Title"]</h1> <div class="container py-4">
<p class="text-danger">You do not have access to this resource.</p> <div class="empty">
</header> <div class="empty-header">Access Denied</div>
<p class="empty-title">You're not allowed to enter this area</p>
<p class="empty-subtitle text-muted">Your account does not have permission to access this area. Contact an administrator.</p>
<div class="empty-action">
<a asp-action="Index" asp-controller="Home" class="btn btn-primary" onclick="history.go(-1)">Take me back</a>
</div>
</div>
</div>
</div>
<audio autoplay>
<source src="~/static/access-denied.mp3" type="audio/mp3" />
</audio>

View file

@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize] [Authorize(Roles = "Administrator")]
public class ArchivesController : Controller public class ArchivesController : Controller
{ {
private readonly DatabaseContext Context; private readonly DatabaseContext Context;

View file

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authorization;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize] [Authorize(Roles = "Administrator")]
public class CompaniesController : Controller public class CompaniesController : Controller
{ {
private readonly DatabaseContext _context; private readonly DatabaseContext _context;

View file

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authorization;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize] [Authorize(Roles = "Administrator")]
public class GamesController : Controller public class GamesController : Controller
{ {
private readonly DatabaseContext Context; private readonly DatabaseContext Context;

View file

@ -2,11 +2,13 @@
using LANCommander.Data; using LANCommander.Data;
using LANCommander.Data.Models; using LANCommander.Data.Models;
using LANCommander.Models; using LANCommander.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize]
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;

View file

@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authorization;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize] [Authorize(Roles = "Administrator")]
public class TagsController : Controller public class TagsController : Controller
{ {
private readonly DatabaseContext _context; private readonly DatabaseContext _context;

View file

@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc;
namespace LANCommander.Controllers namespace LANCommander.Controllers
{ {
[Authorize] [Authorize(Roles = "Administrator")]
public class UploadController : Controller public class UploadController : Controller
{ {
private const string UploadDirectory = "Upload"; private const string UploadDirectory = "Upload";

Binary file not shown.