diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 2d1160ab4..cb665c2df 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -98,9 +98,12 @@ function getCallbacks (req, res) { const secret = process.env.NEXTAUTH_SECRET const jwt = await encodeJWT({ token, secret }) const me = await prisma.user.findUnique({ where: { id: token.id } }) - // we set multi_auth cookies on login/signup with only one user so the rest of the code doesn't - // have to consider the case where they aren't set yet because account switching wasn't used yet - setMultiAuthCookies(req, res, { ...me, jwt }) + const hasMultiAuth = !!req.cookies['multi_auth.user-id'] + if (!hasMultiAuth) { + // we set multi_auth cookies on login/signup with only one user so the rest of the code doesn't + // have to consider the case where they aren't set yet because account switching wasn't used yet + setMultiAuthCookies(req, res, { ...me, jwt }) + } } return token