-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix validation of provider existence before looking for protection property #1687
fix validation of provider existence before looking for protection property #1687
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/nextauthjs/next-auth/4W7Nv3eEJaC5N5mP5DzM8tJgbQaw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
can we just useboptional chaining?
provider?.protection
Done, I used regular short-circuit evaluation to keep code style used on line 75. |
That if check in line 75 is a mess... 😂 Thank you for this fix! |
🎉 This PR is included in version 3.14.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 4.0.0-next.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…ty (nextauthjs#1687) * Fix validation of provider existence before looking for protection property * Use optional chaining
What:
Validate provider exists before accessing protection property in NextAuthHandler
Why:
NextAuthHandler reads all requests to api, including endpoints that does not include
providerId
as /api/auth/session, on line 73, result of finding a provider with providerId = undefined, is an undefined provider, that leads to anUnhandledPromiseRejectionWarning: TypeError: Cannot read property 'protection' of undefined
on line 82.How:
Validate provider exists before accessing protection property.
Checklist:
Fixes #1686