From 48543c7ff03b1ff4b3efa96de56097fb9ada2f02 Mon Sep 17 00:00:00 2001 From: whoswhip Date: Sun, 4 Jan 2026 09:55:15 -0500 Subject: [PATCH] fix: update API routes for fetching raw paste content and deleting pastes --- SharpbinV3.Client/src/routes/[id]/+page.server.ts | 2 +- SharpbinV3.Server/Controllers/PasteController.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SharpbinV3.Client/src/routes/[id]/+page.server.ts b/SharpbinV3.Client/src/routes/[id]/+page.server.ts index d567f97..5f5d9c4 100644 --- a/SharpbinV3.Client/src/routes/[id]/+page.server.ts +++ b/SharpbinV3.Client/src/routes/[id]/+page.server.ts @@ -12,7 +12,7 @@ export const load: PageServerLoad = async ({ params, fetch }) => { }; } const pasteData = (await paste.json()) as Paste; - const pasteContent = await fetch(`/api/paste/raw/${id}`); + const pasteContent = await fetch(`/api/paste/${id}/raw`); const pasteOptions = await fetch('/api/paste/create/options'); const options = await pasteOptions.json(); const content = await pasteContent.text(); diff --git a/SharpbinV3.Server/Controllers/PasteController.cs b/SharpbinV3.Server/Controllers/PasteController.cs index 582f1bc..135f1e9 100644 --- a/SharpbinV3.Server/Controllers/PasteController.cs +++ b/SharpbinV3.Server/Controllers/PasteController.cs @@ -77,7 +77,7 @@ namespace SharpbinV3.Server.Controllers }); } [HttpGet] - [Route("raw/{id}")] + [Route("{id}/raw")] public async Task GetRawPasteByID(string id) { var paste = await _pasteService.Get(id); @@ -109,7 +109,7 @@ namespace SharpbinV3.Server.Controllers .Where(c => c.Type == ClaimTypes.Role) .Select(c => int.Parse(c.Value)) .Any(r => r == 1 || r == 255); - if (paste.AuthorUUID != Guid.Parse(uuidClaim) || !hasPrivilegedRole) + if (paste.AuthorUUID != Guid.Parse(uuidClaim) && !hasPrivilegedRole) return Forbid(); bool result = await _pasteService.EditText(paste, content); if (!result) return NotFound(); @@ -130,7 +130,7 @@ namespace SharpbinV3.Server.Controllers .Where(c => c.Type == ClaimTypes.Role) .Select(c => int.Parse(c.Value)) .Any(r => r == 1 || r == 255); - if (paste.AuthorUUID != Guid.Parse(uuidClaim) || !hasPrivilegedRole) + if (paste.AuthorUUID != Guid.Parse(uuidClaim) && !hasPrivilegedRole) return Forbid(); if (request.Title != null) paste.Title = request.Title; @@ -170,7 +170,7 @@ namespace SharpbinV3.Server.Controllers }); } [HttpDelete] - [Route("{id}")] + [Route("{id}/delete")] [Authorize] public async Task DeletePaste(string id) { @@ -183,7 +183,7 @@ namespace SharpbinV3.Server.Controllers .Where(c => c.Type == ClaimTypes.Role) .Select(c => int.Parse(c.Value)) .Any(r => r == 1 || r == 255); - if (paste.AuthorUUID != Guid.Parse(uuidClaim) || !hasPrivilegedRole) + if (paste.AuthorUUID != Guid.Parse(uuidClaim) && !hasPrivilegedRole) return Forbid(); bool result = await _pasteService.Delete(paste); if (!result) return NotFound();