refactor(auth): streamline logout route and update route tree for logout integration
Build and Push Auth Portal Docker Image / build-and-push (push) Successful in 3m15s
Build and Push Auth Portal Docker Image / create-release (push) Skipped

This commit is contained in:
Denozordec
2026-07-18 18:36:21 +07:00
parent 2a6adf7af8
commit a4ece3d344
5 changed files with 69 additions and 19 deletions
+12 -16
View File
@@ -91,22 +91,18 @@ export async function authRoutes(app: FastifyInstance): Promise<void> {
},
})
app.post(
'/api/v1/auth/logout',
{ onRequest: requireAuth },
async (request, reply) => {
const cookie = request.headers.cookie ?? ''
const match = cookie.match(new RegExp(`${REFRESH_COOKIE}=([^;]+)`))
if (match?.[1]) {
revokeRefreshSession(app.db, match[1])
}
reply.header(
'Set-Cookie',
`${REFRESH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`,
)
return { ok: true }
},
)
app.post('/api/v1/auth/logout', async (request, reply) => {
const cookie = request.headers.cookie ?? ''
const match = cookie.match(new RegExp(`${REFRESH_COOKIE}=([^;]+)`))
if (match?.[1]) {
revokeRefreshSession(app.db, match[1])
}
reply.header(
'Set-Cookie',
`${REFRESH_COOKIE}=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0`,
)
return { ok: true }
})
app.get(
'/api/v1/auth/me',