-
-
Notifications
You must be signed in to change notification settings - Fork 88
Conversation
e15fbb1
to
0e31ad2
Compare
const newObjectobject: any = {} | ||
for (const key in object) { | ||
const value = object[key] | ||
if (value === undefined) continue |
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.
👋 I've been playing around with this branch on a personal project and noticed a small issues when using the GoogleProvider
for authentication. This line specifically checks for undefined
, but in the case of a response from Google where emailVerified
=== null
, reading the value below in fromFirestore
on value.toDate
will throw:
https://next-auth.js.org/errors#session_error Cannot read property 'toDate' of null TypeError: Cannot read property 'toDate' of null
Not sure what the best approach would be here but maybe you either want to:
- Exclude
null
values from when writing to firebase (probably not ideal and not recommended sincenull
is a valid datatype) or... - Ensuring
value
is defined below, before callingtoDate()
. I'll leave a suggestion below, or.. - All of above 🤷 Again, maybe not ideal since
null
is a valid datatype but you have more context than me 😅
packages/firebase/src/index.ts
Outdated
const newUser: any = { ...snapshot.data(), id: snapshot.id } | ||
for (const key in newUser) { | ||
const value = newUser[key] | ||
if (value.toDate) newUser[key] = value.toDate() |
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.
if (value.toDate) newUser[key] = value.toDate() | |
if (value && value.toDate) newUser[key] = value.toDate() |
or even better
if (value.toDate) newUser[key] = value.toDate() | |
if (value?.toDate) newUser[key] = value.toDate() |
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.
had the same issue with firebase v9. this fix works great.
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.
Thank you for your suggestion! Awesome!
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.
yes, this solve the issue and it work in localhost. However, when i tried to deploy to Vercel, it could be build successfully, but it would have problem when login with google. When login with the google, it always show callback error, but in the localhost environmnet, there is no issue. is threre anything i should concern?
Hi! Is this pull request in a usable state? |
* cleanup FirebaseClient * fix undefined issue * fix tests
Does anyone know how to use @next-auth/firebase-adapter with NextAuth.js version 4? |
@balazsorban44 Please see https://github.com/nextauthjs/adapters/issues/180#issuecomment-1004126562. The issue has been closed by stale bot. I also have firebase auth working here #363. Need some feedback to see what more can be done. |
@balazsorban44 is there any chance to upgrade firebase adapter in the near future? |
This repository has been merged into a monorepo. Follow-up PR is here: nextauthjs/next-auth#3873 |
Ports and refactors `@next-auth/firebase-adapter` to use the new Adapter API. Ported from this PR: nextauthjs/adapters#183 BREAKING CHANGE: - Renames `FirebaseAdapter` export to `FirestoreAdpater` - This adapter now requires firebase v9+
See #171, #182
Firebase introduces a more modular version from 9 and up. The adapter has been rewritten to work with v8. I will see if I can make the upgrade:
https://firebase.google.com/docs/web/learn-more#v9-new-apps
A few things to figure out before we can merge this:
Any help with these would be appreciated! 🙏