Revert website Forbid and Unauthorized method usage to StatusCode

This is because by default ASP.NET expects an authentication scheme to be registered when using these methods.
This commit is contained in:
Slendy 2023-03-30 19:23:11 -05:00
parent 50d1d9c7e5
commit c34b7f3e79
No known key found for this signature in database
GPG key ID: 7288D68361B91428
5 changed files with 8 additions and 8 deletions

View file

@ -105,7 +105,7 @@ public class UserEndpoints : ApiEndpointController
string authToken = authHeader[(authHeader.IndexOf(' ') + 1)..];
ApiKeyEntity? apiKey = await this.database.APIKeys.FirstOrDefaultAsync(k => k.Key == authToken);
if (apiKey == null) return this.Unauthorized();
if (apiKey == null) return this.StatusCode(403);
if (!string.IsNullOrWhiteSpace(username))
{

View file

@ -23,7 +23,7 @@ public class AdminReportController : ControllerBase
public async Task<IActionResult> DeleteReport([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsAdmin) return this.Forbid();
if (user == null || !user.IsAdmin) return this.StatusCode(403);
GriefReportEntity? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
if (report == null) return this.NotFound();
@ -50,7 +50,7 @@ public class AdminReportController : ControllerBase
public async Task<IActionResult> DismissReport([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Forbid();
if (user == null || !user.IsModerator) return this.StatusCode(403);
GriefReportEntity? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
if (report == null) return this.NotFound();

View file

@ -21,7 +21,7 @@ public class ModerationCaseController : ControllerBase
public async Task<IActionResult> DismissCase([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Forbid();
if (user == null || !user.IsModerator) return this.StatusCode(403);
ModerationCaseEntity? @case = await this.database.Cases.FirstOrDefaultAsync(c => c.CaseId == id);
if (@case == null) return this.NotFound();

View file

@ -24,7 +24,7 @@ public class ModerationSlotController : ControllerBase
public async Task<IActionResult> TeamPick([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Unauthorized();
if (user == null || !user.IsModerator) return this.StatusCode(403);
SlotEntity? slot = await this.database.Slots.Include(s => s.Creator).FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound();
@ -43,7 +43,7 @@ public class ModerationSlotController : ControllerBase
public async Task<IActionResult> RemoveTeamPick([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Unauthorized();
if (user == null || !user.IsModerator) return this.StatusCode(403);
SlotEntity? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound();
@ -59,7 +59,7 @@ public class ModerationSlotController : ControllerBase
public async Task<IActionResult> DeleteLevel([FromRoute] int id)
{
UserEntity? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Unauthorized();
if (user == null || !user.IsModerator) return this.StatusCode(403);
SlotEntity? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.Ok();

View file

@ -18,7 +18,7 @@ public class AuthenticationPage : BaseLayout
public IActionResult OnGet()
{
if (this.User == null) return this.Forbid();
if (this.User == null) return this.Redirect("~/login");
this.IpAddress = this.HttpContext.Connection.RemoteIpAddress;