mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Enhance paste management and user interface
- Updated `AuthController.cs` to include user `Type` in responses. - Added `DeletePaste` and `ChangePasteID` endpoints in `PasteController.cs` with authentication and error handling. - Removed `Logging.cs`, indicating a refactor of the logging mechanism. - Implemented methods for deleting and updating paste IDs in `DatabaseService.cs`. - Modified `SharpbinV2.Server.csproj` to exclude `logs` and `pastes` directories from compilation. - Enhanced `paste.css` with styles for an edit icon. - Introduced `userTypes` object in `dash.js` for better role management. - Added delete button functionality in `paste.js` for authorized users. - Updated `paste.html` to include edit and delete buttons for improved user experience.
This commit is contained in:
@@ -163,6 +163,37 @@ function addInfo(paste) {
|
||||
document.getElementById("raw-button").addEventListener("click", function () {
|
||||
window.location.href = `/raw/${paste.id}`;
|
||||
});
|
||||
|
||||
waitForAuthData().then(() => {
|
||||
if (authData.user.uuid === paste.authorUUID || authData.user.type === 255) {
|
||||
document.getElementById("delete-button").style.display = "inline-block";
|
||||
document.getElementById("delete-button").addEventListener("click", function () {
|
||||
if (confirm("Are you sure you want to delete this paste?")) {
|
||||
fetch(`/api/pastes/${paste.id}`, {
|
||||
method: "DELETE"
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
showNotification("Paste deleted!", "info", 2000);
|
||||
window.location.href = "/";
|
||||
} else {
|
||||
showNotification("Failed to delete paste.", "error", 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function waitForAuthData() {
|
||||
return new Promise((resolve) => {
|
||||
const checkAuth = setInterval(() => {
|
||||
if (authData) {
|
||||
clearInterval(checkAuth);
|
||||
resolve();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function addContent(content, syntax) {
|
||||
|
||||
Reference in New Issue
Block a user