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;
const cookiePrefix = this.config.node.prod ? '__Secure-' : '';
const sessionCookieName = `${cookiePrefix}next-auth.session-token`;
// next-auth credentials login only support JWT strategy
// https://next-auth.js.org/configuration/providers/credentials
// let's store the session token in the database
if (
credentialsSignIn &&
(nextAuthTokenCookie = cookies?.find(
({ name }) => name === 'next-auth.session-token'
({ name }) => name === sessionCookieName
))
) {
const cookieExpires = new Date();