-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Firestore access with User context depends on never called Code? #2864
Comments
This issue does not seem to follow the issue template. Make sure you provide all the required information. |
Your solution worked, thanks. |
Same issue here. Angular 11, @angular/fire 6.1 |
solution worked:
However, what the hell is happening here ? |
Watching the video -- that's freaking nuts. I too am getting permissions issues on Firestore after upgrading to angular 12 and then updating firestore and firebase. It's got nothing to do with the security rules on the Firebase console because I am running the same project in angular 9 side by side! |
This is an issue for me on Angular 11 and Angular 12.
I think this issue should be documented and at least a turnaround should be
proposed. It’s a very strange behavior.
…On Sat, 19 Jun 2021 at 03:43, Steve Brown ***@***.***> wrote:
Watching the video -- that's freaking nuts. I too am getting permissions
issues on Firestore after upgrading to angular 12 and then updating
firestore and firebase. It's got nothing to do with the security rules on
the Firebase console because I am running the same project in angular 9
side by side!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2864 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIWEOLIV674AA3BC3JJUKL3TTPY2LANCNFSM46V3AVFA>
.
|
Thanks! I was going crazy with this problem. It's not just in the Firestore, it's also in the Realtime Database. If you refresh the web page, the authentication causes the user to log in, but has a permission error when getting data (the client does not have permission to access the desired data). Doing that trick solved the problem, but now I get a warning from firebase due to this solution line: "import firebase from 'firebase';" But if I replace the line with the correct one "import firebase from 'firebase / app'; then the problem is still there. The firebase warning is: "It looks like you're using the development build of the Firebase JS SDK. |
Facing the same issue in multiple Firebase projects. We're running: The workaround described in this issue works for us as well if we import like this:
Not to ecstatic about that, but at least it got us going writing code again. |
Using imports of the form
Got things working for me and also removed the warnings. |
So, with that last comment of maguro I tried only with his second import on app-component.ts and it works, at least for me: import "firebase/auth"; no "phantom function" needed (the other import of course where you need it) |
Weird behavior, workaround worked for angular 11.2.4, not in 11.2.14. |
Downgrading to Firebase 8.6.1 works for me. The offending version was 8.6.8. I'm on Angular 12 |
Per this comment there is a v8.7 of the JS SDK soon-to-be released that seems to solve the problem. |
Closing as it's been fixed in the JS SDK. |
Version info
Angular: 12.0.3
Firebase: 8.6.7
AngularFire: 6.1.5
OS: Windows 10
Browser: Chrome
package.json: Open
I basically created an AuthService (Open).
This AuthService is used by a Navbar Component inside the AppComponent to get the Profil Name and Image.
Like this:
There is also a login Button that calls the AuthServices login() function. For now lets just emagine we are already logged in.
In side the AuthService i try to read my userdata from Firestore.
My Firestore rules:
I also have the admin claim.
So normaly i would expect to see my Userdata in the console. But instead i get:
Since i expected it to work and i wasn't able to research a working solution. I asked on Stackoverflow (Open)
Later i found a working solution but this "solution" makes no sense at all.
Solution:
First i add
private afAuth: AngularFireAuth
to the constructor of a random component. It still dosn't work after that.But if i add
this.afAuth.setPersistence(firebase.auth.Auth.Persistence.SESSION);
orthis.afAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider())
anywhere (even if those lines get never called) inside that random Component the AuthService suddenly works and spits out all the data i want. It isn't even necersarry for the Component to be activly used on the Page.Example Video: https://youtu.be/jbEnTLJ9Lmc (The longer you look the worse it gets)
In the video i use the AppComponent but als works with every random Component i tried. AppComponent (Open)
I basically have no idea why that works but it seems very very wrong.
The text was updated successfully, but these errors were encountered: