Skip to content

Commit 31d827a

Browse files
committed
fix: tweak email flow, change homepage
1 parent 49675a2 commit 31d827a

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/next-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "next-auth",
33
"version": "4.24.7",
44
"description": "Authentication for Next.js",
5-
"homepage": "https://next-auth.js.org",
5+
"homepage": "https://authjs.dev",
66
"repository": "https://github.com/nextauthjs/next-auth.git",
77
"author": "Iain Collins <[email protected]>",
88
"contributors": [

packages/next-auth/src/core/routes/callback.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,30 @@ export default async function callback(params: {
199199
}
200200
} else if (provider.type === "email") {
201201
try {
202-
const token = query?.token as string | undefined
203-
const identifier = query?.email as string | undefined
202+
const paramToken = query?.token as string | undefined
203+
const paramIdentifier = query?.email as string | undefined
204204

205205
// If these are missing, the sign-in URL was manually opened without these params or the `sendVerificationRequest` method did not send the link correctly in the email.
206-
if (!token || !identifier) {
206+
if (!paramToken || !paramIdentifier) {
207207
return { redirect: `${url}/error?error=configuration`, cookies }
208208
}
209209

210210
// @ts-expect-error -- Verified in `assertConfig`. adapter: Adapter<true>
211211
const invite = await adapter.useVerificationToken({
212-
identifier,
213-
token: hashToken(token, options),
212+
identifier: paramIdentifier,
213+
token: hashToken(paramToken, options),
214214
})
215215

216-
const invalidInvite = !invite || invite.expires.valueOf() < Date.now()
216+
const invalidInvite =
217+
!invite ||
218+
invite.identifier !== paramIdentifier ||
219+
invite.expires.valueOf() < Date.now()
217220
if (invalidInvite) {
218221
return { redirect: `${url}/error?error=Verification`, cookies }
219222
}
220223

221224
const profile = await getAdapterUserFromEmail({
222-
email: identifier,
225+
email: invite.identifier,
223226
adapter,
224227
})
225228

0 commit comments

Comments
 (0)