Skip to content

Commit

Permalink
fix: Refactor clearing cookies to continue support for own logout end…
Browse files Browse the repository at this point in the history
…point implementation
  • Loading branch information
Evanjt1 committed Jul 17, 2024
1 parent 1071ad9 commit 949752e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ const getCookies = (req: FastifyRequest): Record<string, string> => {
return parseCookies(cookies)
}

const setClearCookies = (reply: FastifyReply) => {
const clearedCookies = createTokenCookies('', '')
reply.header('Set-Cookie', clearedCookies)
}

const validateDPoP = (req: FastifyRequest): string => {
if (!USE_DPOP)
return ''
Expand Down Expand Up @@ -505,7 +510,7 @@ const logoutEndpoint = async (req: FastifyRequest, reply: FastifyReply) => {
const { nonce } = req.body as { nonce?: string }

await logoutUser(nonce || '')
setTokenCookies(reply, '', '')
setClearCookies(reply)

return reply.send({loggedOut: true})
}
Expand Down

0 comments on commit 949752e

Please sign in to comment.