Refactor: Remove server state files and update server log handling
- Deleted server-stopped, server.log, and server.pid files to clean up unused state. - Updated game-page-client.tsx to enhance button accessibility with cursor-pointer class. - Modified not-found.tsx, page.tsx, and profile/page.tsx for consistent cursor-pointer usage on links. - Adjusted search/page.tsx and components/auth/*.tsx for improved button interactions with cursor-pointer. - Refined navbar.tsx for better user experience with cursor-pointer on navigation links. - Updated settings-security-tab.tsx for passkey management API endpoints and improved error handling. - Enhanced saved-games components for better user interaction with cursor-pointer on buttons. - General code cleanup and consistency improvements across various components.
This commit is contained in:
@@ -311,3 +311,84 @@ export const userRoutes = new Elysia({ prefix: "/user" })
|
||||
}),
|
||||
},
|
||||
)
|
||||
// Passkey management endpoints (better-auth doesn't provide these)
|
||||
.post(
|
||||
"/me/passkey/delete",
|
||||
async ({ request, body, set }) => {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
})
|
||||
|
||||
if (!session) {
|
||||
set.status = 401
|
||||
return { error: "Unauthorized" }
|
||||
}
|
||||
|
||||
// Verify the passkey belongs to the user
|
||||
const [pk] = await db
|
||||
.select({ id: passkey.id })
|
||||
.from(passkey)
|
||||
.where(and(
|
||||
eq(passkey.id, body.id),
|
||||
eq(passkey.userId, session.user.id)
|
||||
))
|
||||
.limit(1)
|
||||
|
||||
if (!pk) {
|
||||
set.status = 404
|
||||
return { error: "Passkey not found" }
|
||||
}
|
||||
|
||||
await db
|
||||
.delete(passkey)
|
||||
.where(eq(passkey.id, body.id))
|
||||
|
||||
return { success: true }
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
}),
|
||||
},
|
||||
)
|
||||
.post(
|
||||
"/me/passkey/update",
|
||||
async ({ request, body, set }) => {
|
||||
const session = await auth.api.getSession({
|
||||
headers: request.headers,
|
||||
})
|
||||
|
||||
if (!session) {
|
||||
set.status = 401
|
||||
return { error: "Unauthorized" }
|
||||
}
|
||||
|
||||
// Verify the passkey belongs to the user
|
||||
const [pk] = await db
|
||||
.select({ id: passkey.id })
|
||||
.from(passkey)
|
||||
.where(and(
|
||||
eq(passkey.id, body.id),
|
||||
eq(passkey.userId, session.user.id)
|
||||
))
|
||||
.limit(1)
|
||||
|
||||
if (!pk) {
|
||||
set.status = 404
|
||||
return { error: "Passkey not found" }
|
||||
}
|
||||
|
||||
await db
|
||||
.update(passkey)
|
||||
.set({ name: body.name })
|
||||
.where(eq(passkey.id, body.id))
|
||||
|
||||
return { success: true }
|
||||
},
|
||||
{
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
name: t.String(),
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user