Skip to content

Commit

Permalink
Merge pull request #34 from cipherstash/session-clear
Browse files Browse the repository at this point in the history
feat: clear cookies on logout
  • Loading branch information
calvinbrewer authored Jan 17, 2025
2 parents 6cf307e + 3bb4a10 commit 0cf698e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/friendly-beers-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cipherstash/nextjs": minor
---

Cleared session cookies when a user has logged out.
12 changes: 11 additions & 1 deletion packages/nextjs/src/clerk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ export const jseqlClerkMiddleware = async (
path: '/',
})

const cookie = response.cookies.get(CS_COOKIE_NAME)
response.cookies.get(CS_COOKIE_NAME)
return response
}

if (!userId && ctsSession) {
logger.debug(
'No Clerk token found in the request, so the CipherStash session was reset.',
)

const response = NextResponse.next()
response.cookies.delete(CS_COOKIE_NAME)
return response
}

Expand Down

0 comments on commit 0cf698e

Please sign in to comment.