mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-05 18:48:41 +00:00
fix: update API routes for fetching raw paste content and deleting pastes
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace SharpbinV3.Server.Controllers
|
||||
});
|
||||
}
|
||||
[HttpGet]
|
||||
[Route("raw/{id}")]
|
||||
[Route("{id}/raw")]
|
||||
public async Task<IActionResult> 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<IActionResult> 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();
|
||||
|
||||
Reference in New Issue
Block a user