fix: update API version and restrict set-password to JSON body (Task 7)

This commit is contained in:
2026-05-27 02:52:09 +08:00
parent f059b00f4b
commit 8e9b16349c
3 changed files with 36 additions and 2 deletions
+11
View File
@@ -188,6 +188,13 @@ export const userRoutes = new Elysia({ prefix: "/user", detail: { tags: ["Users"
.post(
"/me/set-password",
async ({ request, body, set }) => {
// Reject non-JSON content types
const contentType = request.headers.get("content-type") || ""
if (!contentType.includes("application/json")) {
set.status = 415
return { error: "Content-Type must be application/json" }
}
const session = await auth.api.getSession({
headers: request.headers,
})
@@ -230,6 +237,10 @@ export const userRoutes = new Elysia({ prefix: "/user", detail: { tags: ["Users"
body: t.Object({
newPassword: t.String({ minLength: 10 }),
}),
detail: {
description: "Set a password for the authenticated user. Requires JSON body.",
tags: ["Users"],
},
},
)
.get(