mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-13 03:26:54 +00:00
Improve API token expiration handling by adding date and time validation and ensuring consistent expiresAt data type.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/97ca9771-6ea6-4874-95e0-c9ca04f36ec8.jpg
This commit is contained in:
@@ -79,7 +79,9 @@ const tokenFormSchema = z.object({
|
||||
role: z.string().min(1, "Role is required"),
|
||||
expiresIn: z.string().optional(),
|
||||
customDate: z.date().optional(),
|
||||
customTime: z.string().optional(),
|
||||
customTime: z.string().regex(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/, {
|
||||
message: "Time must be in 24-hour format HH:MM"
|
||||
}).optional(),
|
||||
}).refine((data) => {
|
||||
// If custom expiration is selected, a date must be provided
|
||||
if (data.expiresIn === 'custom' && !data.customDate) {
|
||||
@@ -89,6 +91,19 @@ const tokenFormSchema = z.object({
|
||||
}, {
|
||||
message: "Please select a date for the custom expiration",
|
||||
path: ["customDate"]
|
||||
}).refine((data) => {
|
||||
// If a custom date is provided, validate it's in the future
|
||||
if (data.customDate) {
|
||||
const now = new Date();
|
||||
const dateOnly = new Date(data.customDate);
|
||||
dateOnly.setHours(0, 0, 0, 0);
|
||||
now.setHours(0, 0, 0, 0);
|
||||
return dateOnly >= now;
|
||||
}
|
||||
return true;
|
||||
}, {
|
||||
message: "Expiration date must be in the future",
|
||||
path: ["customDate"]
|
||||
});
|
||||
|
||||
export default function ApiTokensPage() {
|
||||
|
||||
Reference in New Issue
Block a user