tattwei46 / flutter_login_demo

A demo login app with Flutter and Firebae
369 stars 215 forks source link

Different Auth Account but still Showing Same Todo List #1

Closed komputerboy closed 5 years ago

komputerboy commented 5 years ago

Hi, first i want to thank you for your nice project. I have tried it in, and use my own Firebase JSON file. Now i encounter a problem. Why when i sign in with user A, or user B, etc. It show same list? It's just like there is not specific key based on user id( Auth Id) Ex: When i Sign in with User A and post some todo list. so then todo list is: A B then logout And Sign in with another Account (User B), and it still show same todo list (without posting todo list before), like User A: A B

juancarlosjr97 commented 5 years ago

HI there,

I used this project for guidance to build my own,

Yes, that is one the issues

In order to fix it, you need to create a root users collection in Firestore, and then have todo list per user using the ID of authentification

komputerboy commented 5 years ago

I really sorry but, can you please fix that ? This is my first app using Flutter, so i basically not very understand with Flutter + Firebase. Thanks

tattwei46 commented 5 years ago

Hello all,

Thanks for reporting this issue. I will fix it as soon as possible.

David

komputerboy commented 5 years ago

Thanks

tattwei46 commented 5 years ago

Hello all,

Issue has been fixed. Previously it will show all the todo items irrespective of who created it. Now it only shows todo items created by the same user who logs in.

The Firebase database structure now looks like this:

screenshot 2018-12-25 at 2 00 24 pm

And the query in the app looks like this: _todoQuery = database .reference() .child("todo") .orderByChild("userId") .equalTo(widget.userId);

Kindly get the latest code and validate the fix. Let me know when it's fix so i can close this issue.

In addition i have improve the todo functionality by adding Update and Delete. I will write a post shortly about this and share the link to the post here.

Merry Xmas and Happy New Year, David

komputerboy commented 5 years ago

Okay, now it fixed. Thanks. But there is still an issue. I can't login. It keeps showing progress loading animation. But when i close it, then open it again. I can login

tattwei46 commented 5 years ago

@komputerboy Thanks for verifying fix.

Regarding the loading issue, I cannot reproduce the issue on my side so i cannot debug. But on the safe side i have added few lines of code that will disable the loading once Firebase operation is done.

Please refer to https://github.com/tattwei46/flutter_login_demo/commit/1199c75370dda770fecd1a87ed8a7046ee324e17

I will close this issue as it has been fixed and validated. Kindly open another issue if you still see it.

Thanks, David

komputerboy commented 5 years ago

And more thing.. How to make UserId as Parent Node instead Child. So the Node is like this:

thank you very much

tattwei46 commented 5 years ago

Hi @komputerboy,

Just add .child(widget.user.id) in the path before push

Please find below the code changes:

_addNewTodo(String todoItem) { if (todoItem.length > 0) { Todo todo = new Todo(todoItem.toString(), widget.userId, false); _database.reference().child("todo").child(widget.userId).push().set(todo.toJson()); } }

Also find below the structure in Firebase

screenshot 2018-12-29 at 6 21 26 am

Thanks, David

komputerboy commented 5 years ago

okay, thank you very much