Skip to content

Commit

Permalink
fix(providers): optionally check identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Sep 25, 2024
1 parent d66ee42 commit e0a7d71
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/next-auth/src/core/routes/callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default async function callback(params: {
} catch (error) {
return {
redirect: `${url}/error?error=${encodeURIComponent(
(error as Error).message
(error as Error).message,
)}`,
cookies,
}
Expand Down Expand Up @@ -215,8 +215,10 @@ export default async function callback(params: {

const invalidInvite =
!invite ||
invite.identifier !== paramIdentifier ||
invite.expires.valueOf() < Date.now()
invite.expires.valueOf() < Date.now() ||
// The user might have configured the link to not contain the identifier
// so we only compare if it exists
(paramIdentifier && invite.identifier !== paramIdentifier)
if (invalidInvite) {
return { redirect: `${url}/error?error=Verification`, cookies }
}
Expand Down Expand Up @@ -246,7 +248,7 @@ export default async function callback(params: {
} catch (error) {
return {
redirect: `${url}/error?error=${encodeURIComponent(
(error as Error).message
(error as Error).message,
)}`,
cookies,
}
Expand Down Expand Up @@ -346,7 +348,7 @@ export default async function callback(params: {
return {
status: 401,
redirect: `${url}/error?error=${encodeURIComponent(
(error as Error).message
(error as Error).message,
)}`,
cookies,
}
Expand Down Expand Up @@ -378,7 +380,7 @@ export default async function callback(params: {
} catch (error) {
return {
redirect: `${url}/error?error=${encodeURIComponent(
(error as Error).message
(error as Error).message,
)}`,
cookies,
}
Expand Down

0 comments on commit e0a7d71

Please sign in to comment.