Use Unauthorized instead of Forbid on Website & Api

This commit is contained in:
Slendy 2023-03-29 21:44:16 -05:00
parent b0858448c8
commit a603cdb002
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 4 additions and 4 deletions

View file

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

View file

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