Skip to content

Commit 27b2519

Browse files
authoredOct 2, 2023
fix(next): returns correct status for signing in with redirect: false for route handler (#8775)
* fix: returns status for signing in with credentials provider `redirect: false` * chore: format cookie.ts
1 parent 5f15b07 commit 27b2519

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed
 

Diff for: ‎packages/next-auth/src/core/lib/cookie.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function defaultCookies(useSecureCookies: boolean): CookiesOptions {
114114
path: "/",
115115
secure: useSecureCookies,
116116
},
117-
}
117+
},
118118
}
119119
}
120120

@@ -161,22 +161,22 @@ export class SessionStore {
161161
}
162162
}
163163

164-
/**
164+
/**
165165
* The JWT Session or database Session ID
166166
* constructed from the cookie chunks.
167167
*/
168-
get value() {
169-
// Sort the chunks by their keys before joining
170-
const sortedKeys = Object.keys(this.#chunks).sort((a, b) => {
171-
const aSuffix = parseInt(a.split(".").pop() || "0")
172-
const bSuffix = parseInt(b.split(".").pop() || "0")
168+
get value() {
169+
// Sort the chunks by their keys before joining
170+
const sortedKeys = Object.keys(this.#chunks).sort((a, b) => {
171+
const aSuffix = parseInt(a.split(".").pop() ?? "0")
172+
const bSuffix = parseInt(b.split(".").pop() ?? "0")
173173

174-
return aSuffix - bSuffix
175-
});
174+
return aSuffix - bSuffix
175+
})
176176

177-
// Use the sorted keys to join the chunks in the correct order
178-
return sortedKeys.map(key => this.#chunks[key]).join("")
179-
}
177+
// Use the sorted keys to join the chunks in the correct order
178+
return sortedKeys.map((key) => this.#chunks[key]).join("")
179+
}
180180

181181
/** Given a cookie, return a list of cookies, chunked to fit the allowed cookie size. */
182182
#chunk(cookie: Cookie): Cookie[] {

Diff for: ‎packages/next-auth/src/next/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async function NextAuthRouteHandler(
101101
response.headers.delete("Location")
102102
response.headers.set("Content-Type", "application/json")
103103
return new Response(JSON.stringify({ url: redirect }), {
104+
status: internalResponse.status,
104105
headers: response.headers,
105106
})
106107
}

1 commit comments

Comments
 (1)
Please sign in to comment.