Fix inconsistent session cookie name
This commit is contained in:
parent
09b468660b
commit
74304e2f75
|
@ -20,7 +20,7 @@ const multiAuthMiddleware = (request) => {
|
||||||
const cookiePointerName = 'multi_auth.user-id'
|
const cookiePointerName = 'multi_auth.user-id'
|
||||||
const hasCookiePointer = request.cookies?.has(cookiePointerName)
|
const hasCookiePointer = request.cookies?.has(cookiePointerName)
|
||||||
// is there a session?
|
// is there a session?
|
||||||
const sessionCookieName = '__Secure-next-auth.session-token'
|
const sessionCookieName = 'next-auth.session-token'
|
||||||
const hasSession = request.cookies?.has(sessionCookieName)
|
const hasSession = request.cookies?.has(sessionCookieName)
|
||||||
|
|
||||||
if (!hasCookiePointer || !hasSession) {
|
if (!hasCookiePointer || !hasSession) {
|
||||||
|
|
|
@ -248,6 +248,17 @@ export const getAuthOptions = (req, res) => ({
|
||||||
signIn: '/login',
|
signIn: '/login',
|
||||||
verifyRequest: '/email',
|
verifyRequest: '/email',
|
||||||
error: '/auth/error'
|
error: '/auth/error'
|
||||||
|
},
|
||||||
|
cookies: {
|
||||||
|
sessionToken: {
|
||||||
|
name: 'next-auth.session-token',
|
||||||
|
options: {
|
||||||
|
httpOnly: true,
|
||||||
|
sameSite: 'lax',
|
||||||
|
path: '/',
|
||||||
|
secure: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default (req, res) => {
|
||||||
const cookiePointerName = 'multi_auth.user-id'
|
const cookiePointerName = 'multi_auth.user-id'
|
||||||
const userId = req.cookies[cookiePointerName]
|
const userId = req.cookies[cookiePointerName]
|
||||||
// is there a session?
|
// is there a session?
|
||||||
const sessionCookieName = '__Secure-next-auth.session-token'
|
const sessionCookieName = 'next-auth.session-token'
|
||||||
const sessionJWT = req.cookies[sessionCookieName]
|
const sessionJWT = req.cookies[sessionCookieName]
|
||||||
|
|
||||||
if (!userId || !sessionJWT) {
|
if (!userId || !sessionJWT) {
|
||||||
|
|
Loading…
Reference in New Issue