Extra checks and delete confirmation for pastes

## Copilot Generated Commit Details Below

Enhance auth and UI with notifications and delete confirmation

Enhanced authentication in Program.cs by adding checks for the
logged-in user and ensuring proper response handling. Improved
UI in paste.html and privatepaste.html by adding a confirmation
dialog for deletions and a notification system to inform users
of actions and errors. Added CSS styles to support these new
features with appropriate styling and animations.
This commit is contained in:
whoswhip
2024-10-18 20:44:19 -04:00
parent 49f8911be2
commit 0d5fd3bc5d
3 changed files with 258 additions and 27 deletions
+10 -1
View File
@@ -5,6 +5,7 @@ using Newtonsoft.Json.Linq;
using System.Data;
using System.Text;
using Sharpbin;
using System.Reflection;
class Program
{
@@ -2296,6 +2297,7 @@ class Program
await context.Response.WriteAsJsonAsync(new JObject { ["error"] = "Unauthorized" }.ToString());
return;
}
var user = await GetLoggedInUserAsync(token);
if (user == null)
{
@@ -2304,6 +2306,13 @@ class Program
await context.Response.WriteAsJsonAsync(new JObject { ["error"] = "Unauthorized" }.ToString());
return;
}
if (user.UUID == null)
{
context.Response.StatusCode = 401;
context.Response.ContentType = "application/json";
await context.Response.WriteAsJsonAsync(new JObject { ["error"] = "Unauthorized" }.ToString());
return;
}
var responseJson = new JObject();
responseJson["message"] = "Authenticated";
@@ -2317,7 +2326,7 @@ class Program
context.Response.StatusCode = 200;
context.Response.ContentType = "application/json";
await context.Response.WriteAsJsonAsync(responseJson.ToString());
await context.Response.WriteAsJsonAsync(responseJson);
}));
#endregion