diff --git a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs index 99a9e5b5..a0e96239 100644 --- a/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs +++ b/ProjectLighthouse.Servers.API/Controllers/UserEndpoints.cs @@ -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)) { diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs index f84bcef6..f7bbb8da 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/AdminReportController.cs @@ -23,7 +23,7 @@ public class AdminReportController : ControllerBase public async Task 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 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(); diff --git a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs index da8bffcd..71a92c29 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationCaseController.cs @@ -21,7 +21,7 @@ public class ModerationCaseController : ControllerBase public async Task 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(); diff --git a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs index a2c3602a..df0632e5 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Moderator/ModerationSlotController.cs @@ -24,7 +24,7 @@ public class ModerationSlotController : ControllerBase public async Task 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 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 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(); diff --git a/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs index f49823cd..77ebe6a7 100644 --- a/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/ExternalAuth/AuthenticationPage.cshtml.cs @@ -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;