Introduces POST /login and PATCH /password routes for admin authentication and password management. Adds corresponding schema validation for login and password change, enforces stricter password requirements, and updates adminService with JWT-based profile retrieval and improved token handling.
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const z = require("zod")
|
|
|
|
const uuidSchema = z.object({
|
|
uuid: z.string().uuid()
|
|
})
|
|
|
|
module.exports = {
|
|
GET: {
|
|
headers: z.object({
|
|
"content-type": z.string().regex(/application\/json/i),
|
|
"authorization": z.string().startsWith("Bearer ")
|
|
}),
|
|
query: uuidSchema
|
|
},
|
|
PUT: {
|
|
headers: z.object({
|
|
"content-type": z.string().regex(/application\/json/i),
|
|
"authorization": z.string().startsWith("Bearer ")
|
|
}),
|
|
body: z.object({
|
|
reasonKey: z.string().min(1),
|
|
reasonMessage: z.string().optional(),
|
|
expires: z.number().int().positive().optional()
|
|
}),
|
|
error: {
|
|
code: 400,
|
|
error: "CONSTRAINT_VIOLATION",
|
|
errorMessage: "Invalid ban format"
|
|
}
|
|
},
|
|
DELETE: {
|
|
headers: z.object({
|
|
"content-type": z.string().regex(/application\/json/i),
|
|
"authorization": z.string().startsWith("Bearer ")
|
|
}),
|
|
query: uuidSchema
|
|
}
|
|
} |