fix: cookie name (#4293)

This commit is contained in:
Peng Xiao 2023-09-09 14:42:09 +08:00 committed by GitHub
parent 2db0cec443
commit 46fd732ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,13 +148,15 @@ export class NextAuthController {
} }
let nextAuthTokenCookie: (CookieOption & { value: string }) | undefined; let nextAuthTokenCookie: (CookieOption & { value: string }) | undefined;
const cookiePrefix = this.config.node.prod ? '__Secure-' : '';
const sessionCookieName = `${cookiePrefix}next-auth.session-token`;
// next-auth credentials login only support JWT strategy // next-auth credentials login only support JWT strategy
// https://next-auth.js.org/configuration/providers/credentials // https://next-auth.js.org/configuration/providers/credentials
// let's store the session token in the database // let's store the session token in the database
if ( if (
credentialsSignIn && credentialsSignIn &&
(nextAuthTokenCookie = cookies?.find( (nextAuthTokenCookie = cookies?.find(
({ name }) => name === 'next-auth.session-token' ({ name }) => name === sessionCookieName
)) ))
) { ) {
const cookieExpires = new Date(); const cookieExpires = new Date();