Skip to content

Commit

Permalink
Fix enableTokens check
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarscher committed Dec 21, 2023
1 parent 90a537e commit 7ecc3f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/api/src/auth/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const signInWithEmail = async (
await updatePassword(ctx, email, password)
}
const session = await createSession(ctx.auth, authMethod.userId)
if (setCookie) {
if (!ctx.enableTokens && setCookie) {
const cookie = ctx.auth.createSessionCookie(session.id)
setCookie(cookie.serialize())
}
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/routes/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const signInWithAppleIdTokenHandler =
idTokenClaims: payload,
})
const session = await createSession(ctx.auth, user.id)
if (ctx.enableTokens && ctx.setCookie) {
if (!ctx.enableTokens && ctx.setCookie) {
ctx.setCookie(ctx.auth.createSessionCookie(session.id).serialize())
}
return { session }
Expand Down Expand Up @@ -247,7 +247,7 @@ const signInWithEmailCodeHandler =
console.log('calling update passing and invalidate sessions')
await ctx.auth.invalidateUserSessions(res.session?.userId)
const session = await createSession(ctx.auth, res.session?.userId)
if (ctx.enableTokens && ctx.setCookie) {
if (!ctx.enableTokens && ctx.setCookie) {
ctx.setCookie(ctx.auth.createSessionCookie(session.id).serialize())
}
res.session = session
Expand Down Expand Up @@ -342,7 +342,7 @@ export const userRouter = router({
email: input.email,
})
const session = await createSession(ctx.auth, user.id)
if (ctx.enableTokens && ctx.setCookie) {
if (!ctx.enableTokens && ctx.setCookie) {
ctx.setCookie(ctx.auth.createSessionCookie(session.id).serialize())
}
return { session }
Expand Down

0 comments on commit 7ecc3f7

Please sign in to comment.