mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
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:
+10
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user