Skip to content

Commit 0cf698e

Browse files
authored
Merge pull request #34 from cipherstash/session-clear
feat: clear cookies on logout
2 parents 6cf307e + 3bb4a10 commit 0cf698e

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

.changeset/friendly-beers-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cipherstash/nextjs": minor
3+
---
4+
5+
Cleared session cookies when a user has logged out.

packages/nextjs/src/clerk/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@ export const jseqlClerkMiddleware = async (
6767
path: '/',
6868
})
6969

70-
const cookie = response.cookies.get(CS_COOKIE_NAME)
70+
response.cookies.get(CS_COOKIE_NAME)
71+
return response
72+
}
73+
74+
if (!userId && ctsSession) {
75+
logger.debug(
76+
'No Clerk token found in the request, so the CipherStash session was reset.',
77+
)
78+
79+
const response = NextResponse.next()
80+
response.cookies.delete(CS_COOKIE_NAME)
7181
return response
7282
}
7383

0 commit comments

Comments
 (0)