Skip to content
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

uid of previous logged in user is kept when accessing AngularFireDatabase #3

Open
lmeijdam opened this issue Oct 5, 2017 · 0 comments

Comments

@lmeijdam
Copy link

lmeijdam commented Oct 5, 2017

Hey Todd!

Awesome job on your course! Still enjoying watching!

It got me motivated to build something similar, where I found a small issue;
Whenever I log in, the AuthService has;
get user() { return this.af.auth.currentUser; }

But it returns just an Object, After logging into another account, the AuthService (as it is singular) doesn't update this .currentUser property. It keeps track of my previous account.

In MealsService (also singular);
meals$: Observable<Meal[]> = this.db.list(meals/${this.uid}`)

get uid() {
console.log(this.authService.user.uid)
return this.authService.user.uid; // still returns old UID
}
`

There will be an exception that the newly logged in user is not permitted to access the firebase.db.list.

Suggested solution;
In the constructor of the MealsService, listen to the 'authState' object of the AuthService as this returns an Observable<fb.user>. Let me know what you think and if you have a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant