-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
Unhandled Rejection (TypeError): Cannot read property 'roles' of null #24
Comments
As I can see, dbUser can't be null if there is authUser, so this error shouldn't happen if you don't remove the user data while it is authenticated |
@edguerrade I didn't remove the user, the user exist in my db. But after I delete and reauth the user now it worked. |
Hello, I'm a beginner in firebase, and have the same issue. DId you remove the user in firebase db to solve it? |
I guess this bug happens when you are in between of the implementation of the authentication user and database user. My advice is to start from a clean slate by
|
Correct. I deleted everything and start over and it worked. I can't
remember how to reproduce the bug though.
…On Wed, Feb 6, 2019, 1:33 PM Robin Wieruch ***@***.*** wrote:
I guess this bug happens when you are in between of the implementation of
the authentication user and database user. My advice is to start from a
clean slate by
- deleting the user in the Authentication Database (see Authentication
Tab on Firebase Dashboard)
- deleting the user in the Realtime Database (see Database Tab on
Firebase Dashboard)
- busting the cache of the application, because of local-storage (see
screenshot)
[image: screen shot 2019-02-06 at 13 29 37]
<https://user-images.githubusercontent.com/2479967/52322331-bcb16b80-2a13-11e9-8e38-4fafb3b27d68.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACqqnUKxnO9PmNRYp---FIKD7Qlct6P0ks5vKmkmgaJpZM4ahJ_K>
.
|
I'm having the same issue |
Did you try #24 (comment) @oximer ? |
Tried. But doesn’t work. Followed all 3 steps. Still getting the same error. Although I started with a clean slate. |
Figured it out. Instead of defining the roles in Sign Up like roles[ROLES.ADMIN] = ROLES.ADMIN; |
Hi guys None of these fixes are working for me, it all started with Facebook login - is anyone aware of any other fixes?? I'm even having the same problem using the author's code :( edit: Currently backtracking to before adding FB login Thanks Terry |
Right, still the same bug - this is a big problem - I've followed the code to the letter and keep coming back to the same issue. I have users in my DB - the problem appears to be 'roles' crashing the app every time - does anybody have a workaround for this? I've basically lost 15+ hours trying to resolve this. Any tips most welcomed. |
Can you share your code? Any link to a GitHub project? Otherwise we can just guess what's going on. |
Hi Robin
Thanks for getting back to me, I think it's resolved now - I went back to
one of my earlier commits and went through it all again - the part where we
refactored the App/Index component back to a functional component - copying
over the functionality to the withAuthentication component was what got me,
I didn't clear everything out so (I think) the app component kept resetting
user to null.
Apologies for not posting code, I saw a 'bug' tag applied to the thread and
just wondered if it had been resolved - it's been a long day, wasn't
thinking straight...lol
Thoroughly enjoying the course, learning a lot and will definitely be
recommending it.
Thanks again
Terry
…On Wed, 24 Apr 2019 at 17:53, Robin Wieruch ***@***.***> wrote:
Can you share your code? Any link to a GitHub project? Otherwise we can
just guess what's going on :(
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABDQULA7YHUCRW7SNQSUPBTPSDCDLANCNFSM4GUET7FA>
.
|
HI Robin
So, it seems I was mistaken - after retracing my steps and literally
recreating the whole application the same error occurred at exactly the
same point again - the Facebook authentication - upon attempting to log in
with FB it threw exactly the same error message.
[image: image.png]
I even tried replacing my firebase.js with yours to see if it was my code
and no change.
Here's a link to my Github repo:
https://github.com/eltel/reactFirebase
- any tips greatly appreciated - it's all gone so well up to this point
and I'm super keen to get this finished.
Many thanks
Terry
On Wed, 24 Apr 2019 at 19:04, Terry Mitchell <[email protected]>
wrote:
… Hi Robin
Thanks for getting back to me, I think it's resolved now - I went back to
one of my earlier commits and went through it all again - the part where we
refactored the App/Index component back to a functional component - copying
over the functionality to the withAuthentication component was what got me,
I didn't clear everything out so (I think) the app component kept resetting
user to null.
Apologies for not posting code, I saw a 'bug' tag applied to the thread
and just wondered if it had been resolved - it's been a long day, wasn't
thinking straight...lol
Thoroughly enjoying the course, learning a lot and will definitely be
recommending it.
Thanks again
Terry
On Wed, 24 Apr 2019 at 17:53, Robin Wieruch ***@***.***>
wrote:
> Can you share your code? Any link to a GitHub project? Otherwise we can
> just guess what's going on :(
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#24 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABDQULA7YHUCRW7SNQSUPBTPSDCDLANCNFSM4GUET7FA>
> .
>
|
So, after spending many more hours trying to work around this, I've still had no joy - the current GH repo has @Parv3sh solution:
but that didn't change anything, my original code followed the book: const roles = {}; Here is my current repo again: https://github.com/eltel/reactFirebase I even tried pasting in Robin's code and no change. I'm literally losing what little hair I've got left over this, I rebuilt from scratch just to reach the exact same error :( If anyone has a working repo I can compare with I'd be eternally grateful if you could share. Thanks Terry |
Hi @rwieruch - is there any news on this yet? I posted my repo and have hit a brick wall with this course. Many thanks Terry |
So, I gave up on getting Facebook to work - once I removed FB auth from the equation I managed to get the app to work with Twitter and Google login - but this is happening with both mine and @rwieruch 's code with exactly the same error message, I followed all the instructions to the letter and have had no trouble getting FB auth to work in other projects - so it would appear that it's definitely an issue with the 'roles' code as that's the exact same error being thrown with both of our code - is anybody else having this problem?? How did you get around it? |
@eltel Did you try getting rid of roles prop where ever you're using it to sign in a user using facebook? Since you're not assigning an Admin role to that. I think this should work for you. |
@eltel I tried giving a hit on your code. Couldn't reproduce the error though. Try above-mentioned solution first, hence or otherwise, walk me through for reproducing the error. |
@eltel my suggestion at #24 (comment) might still not work for you since you're getting the error in firebase.js. Couple things, you might want to look into.
If above doesn't work. Try below, which I did. I used your code. changed nothing but firebase config since I created a new project for it.
If nothing works, then the way
is defined, needs to be changed. Nonetheless, it's working totally fine at my end using your code. Closes: #24 |
Thanks, man, I'd done all of these beforehand - but the fact that it's only Facebook login that was giving me grief made it clear that there is where the problem was. I had followed @rwieruch 's post (https://www.robinwieruch.de/firebase-facebook-login/) to the letter...However, after recreating the Facebook app and following your first set of instructions - to quote your good self - 'boom! I'm in!! You just got a whole heap of karma points mate, many thanks once again!! :) |
Glad to help. 👍 |
Super thankful for your help @Parv3sh It's so difficult for me to go through all issues for my projects recently, because there is only so much time I can put in to help with individual bugs and the lists of my open source projects keeps growing... That's why I am so grateful when I see the community sticking together to work on such issues. Thank you again and sorry @eltel for not being able to help here. I do my best to keep up with everything, but sometimes I cannot reply in time for issues :( |
Thanks to both of you, no worries Robin, I completely understand - @Parv3sh
<https://github.com/Parv3sh> helped loads and I found the course immensely
useful/educational and am now using the book and code from the course for
reference/scaffold for my own projects.
…On Mon, 6 May 2019 at 10:46, Robin Wieruch ***@***.***> wrote:
Super thankful for your help @Parv3sh <https://github.com/Parv3sh> It's
so difficult for me to go through all issues for my projects recently,
because there is only so much time I can put in to help with individual
bugs and the lists of my open source projects keeps growing... That's why I
am so grateful when I see the community sticking together to work on such
issues. Thank you again and sorry @eltel <https://github.com/eltel> for
not being able to help here. I do my best to keep up with everything, but
sometimes I cannot reply in time for issues :(
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABDQULDFOO24X54LFBYUPUTPUAZEVANCNFSM4GUET7FA>
.
|
Basically all three (Google, Facebook and Twitter) do the same for It seems that |
@vr1e did you fill Auth consent screen? |
It seems that google and facebook logins somehow sorted themselves. Maybe it needed some time... |
Hi. I know this is an old issue, but I am currently facing this problem. I have only setup one method for authentication i.e. Email / Password. Steps to reproduce
Expected behaviorUser is successfully signed up & signed in, then authUser is updated successfully after being merged with dbUser which is read from the database in ...
// *** Merge authUser & dbUser API ***
onAuthUserListener = (next, fallback) =>
this.auth.onAuthStateChanged(authUser => {
if(authUser) {
this.user(authUser.uid)
.get()
.then(doc => {
const dbUser = doc.data();
// if no roles, default to empty roles
if (!dbUser.roles) {
dbUser.roles = {};
}
// merge authUser & dbUser
authUser = {
uid: authUser.uid,
email: authUser.email,
displayName: authUser.displayName,
emailVerified: authUser.emailVerified,
providerData: authUser.providerData,
...dbUser,
};
next(authUser);
});
} else {
fallback();
}
});
... Actual behaviorError: From my personal investigation, it seems as though dbUser is not being read from the database. This causes the dbUser variable to be undefined which throws the above error. I'm not able to figure out why. Current workaroundIt seems as though refreshing the browser after you Sign Out, BUT, before you Sign Up a new user prevents the above error from happening. RepositoryA repository with the code that gives me the above error is available here. **** UPDATE ***This seems to be a Firebase JS SDK issue as there are a few related issues raised on the official Github repository, e.g. here. |
i just fixed it.
Admin
|
this block of code in firebase.js is throwing an error:
//if (!dbUser.roles) {...}
error
Unhandled Rejection (TypeError): Cannot read property 'roles' of null
The text was updated successfully, but these errors were encountered: