Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: storedSessions get returns object not string #5727

Merged
merged 5 commits into from
May 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-bears-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-next/keystone": patch
---

Fixed a bug in `storedSessions` not correctly identifying the current `sessionId`.
6 changes: 4 additions & 2 deletions packages-next/keystone/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ export function storedSessions({
let isConnected = false;
return {
async get({ req, createContext }) {
let sessionId = await get({ req, createContext });
const data = (await get({ req, createContext })) as { sessionId: string } | undefined;
const sessionId = data?.sessionId;
if (typeof sessionId === 'string') {
if (!isConnected) {
await store.connect?.();
Expand All @@ -207,7 +208,8 @@ export function storedSessions({
return start?.({ res, data: { sessionId }, createContext }) || '';
},
async end({ req, res, createContext }) {
let sessionId = await get({ req, createContext });
const data = (await get({ req, createContext })) as { sessionId: string } | undefined;
const sessionId = data?.sessionId;
if (typeof sessionId === 'string') {
if (!isConnected) {
await store.connect?.();
Expand Down