Flutter - Beyond Firebase Auth - User Roles with Firestore
ฝัง
- เผยแพร่เมื่อ 8 ก.ย. 2024
- In this tutorial you will learn Signup user using firebase auth, save user details to firestore, manage user roles using firestore, save user device details and more tips.
Source code (github.com/loh...)
_______________________________________________
♥ Become a Patreon supporter: / reactbits
_______________________________________________
Repository of my UI Challenges (github.com/loh...)
Download from Play Store (play.google.co...)
Download from App Store (apps.apple.com...)
** -------------------------------------------------------------------------------- **
Let's get connected
github.com/loh...
reactbits
lohanida...
/ lohani.damodar
/ lohanidamodar
/ lohanidamodar
hello I love what you done it's a nice tuto. hope you will continue to help others by doing more vidéos like that
Thank you been looking for this ❤️
Thank you. Very good video
Firebase Auth made updates for October. There were lots of changes made. Firebase Auth and User. Dart now conflicts with eachother when importing.
I am using 0.18.1+1 and the version released is 0.18.1+2, and change-log specifies only minor change, and the code is also working fine. I am not sure what you are referring to.. If you have any issue, create a issue in github, provide proper information, code and errors
Read documents in official flutter website there are very few commands only changed and that more easy access commands
if you can make a video "how to create a profilepage and update dataprofile", i think i come to your house i bring you a italian pizza
thank you
you are the best
thanks a lot man. You saved me.
Thanks man you are just awesome..
You're welcome!
Hi Damodar, first of all THANK YOU for both great videos about User Roles and Login. Your videos are from around 8 month ago and maybe because of changes in the meantime I receive errors in main.dart and admin_home.dart. Maybe you can help about what changed in Flutter version. My errors belong to "if (user['role'] == 'admin') {" and error message says: "The operator [] isn't defined for the type Object. Try defining the operator '[]'". There is in Andoid Studio a red waveline under ['role'].
With changes in dart language like null safety and other improvements, these errors are coming. you can make `user['role']` to `(user as Map)['role']`. You need to explicitly define types and it should work.
Have u corrected your error
Even i am.getting d same error
@@appwriters
What are the changes that we need to make if we get the above error
hey if you are still having this error just remove the " .data()" in "snapshot.data.data()"
you are love. solved my big problem. ThankYou soo much.. how to save "name" in database throuh signup
Same as any way you save any other value, you can update once the user is created to store the name or update on firebase auth and database as well.
@@appwriters Thankyou.
@@appwriters bro getting null for name while doing creating an account. Is it possible to pass name which user provides in sign up form to our firestore db?
I struggling with this for 3 days now.
If yes, which dart file needs to be updated
Thanks
Could you please update the description of this video to show timestamps for chapters of your video?
I have a problem in a main.dart when i logged =>
" The method '[]' was called on null.
Receiver: null
Tried calling: []("role") "
Compare you code with the code in the github repository.
did u got the solution ? please help because i stack to this also
@@doctork2579 tell me if it works for you
I think it's because of your login page doesn't send user to any screen. Try to use navigator to go your main screen and if user can go main screen successfully then it will add datas to your Firestore Cloud.
upp! can someone help? what's the solution for this?
pls make the video for the admin only create the users that means admin must create the user,user role,remove the user, update user position
When I press on login it does not take me to the another page still in log in page
You should please compare your code to the code in the repository!
Where in this project did you use the splash screen. I see it as part of your repo but I cannot see where you used it in the project. Great job done though
Very thank's
Hello, great tutorial.
I was wondering if this way of roll based checking would have any sort of security issues, also, can you do a roll based video using firebase custom tokens?
If you apply the same role based checking as well in the Firestore Security rules, then there should not be any security issue.
Thx from Turkey
Thank you too! for your support
oo topram
What if you want your Home Screen on your main dart to be your splash page? How would you make the first screen your splash page but still get user data from the main screen?
Best implement some state management to do it properly. Check my flutter firebase starter ( github.com/lohanidamodar/flutter_firebase_starter )
pls make the video for the admin only create the users
Good video brother
is there an updated version of this video?
Sorry, no, but most of the concepts should work in any version
hellow sir , can you make a video using using getx with role based, its bit challenge out here
I have developed an app with admin
But the problem is admin is going logged by the same email and password which is registered for user
I want differentiate between both admin user so that admin only can log by his own email pass. How to do that
From what I understand,
There might be two ways, server side claims and roles in firestore, firebase.google.com/docs/firestore/solutions/role-based-access
I have a tutorial here that is a bit old but might help you understand roles in firestore. th-cam.com/video/A0Fn5pgDTn0/w-d-xo.html
Can you please make a video on role based using react and firestore
Sorry, not doing react for quite some time now, But if you understand roles here, it should be similar to how you implement in react
In my app, there is an Auditorium booking system, VC Appointment System, and Cafe Details
.
Now the above three system handle by three different users means when someone wants to meet VC he can request to the VC Personal assistant that I want an appointment the assistant send a message to the user that your appointment is fixed. Similarly, for Auditorium booking and the Cafe manager add the items so the user can see the items and price of food now I want to show auditorium admin to his page and for VC admin and cafe manager so how would I do that.'
That means they all are not same admin, they all have different role, so you have to handle separately.
@@appwriters How to handle it. Can you give me some guideline please I need this?
bro did you find a solution
@@1stplace362 no
Yo......you look like a bald Tekashi69.....dope tutorial though. I definitely needed this.
Thank you!
how to assign multiple roles like if there is more than one admin then we should use else if or something else??
Not sure if I understand your query fully. If you want to assign multiple roles for same user you can use Array (roles: super_admin,admin,customer) or you can use multiple boolean fields like (super_admin: true, admin:true, customer:true).
@@appwriters I want to assign roles to a different user I am developing an app in which there are 15 admins so how can I do that like as in the video you used if-else statement that if the role is admin then return AdminPage now I want to add more admins so should I used another if-else statement
i need to implement the same process in my app but I m using phone authentication instead of email/password. can you help me out with what changes should I make?
If you can make phone auth work, then only thing to do is in firestore save by phone number. everything else should be the same.
@@appwriters where to save by phone number and how? I m very much new to flutter and non-tech background.
my phone auth is working fine. I just copied your code and tried to make it work mine. but I am unable to create stream builder for auth change. please look into it. thanks for reply.
how can i add name on my Map data
if i want show all admin in user_home_page.. what code should i write for this??
I am not sure I understand your question?
@@appwriters want to show all admin list in user's home page.
I want to assign roles to a different user I am developing an app in which there are 15 admins so how can I do that like as in the video you used the if-else statement that if the role is admin then return AdminPage now I want to add more admins so should I used another if-else statement
What do you mean? Even if you add 1000 admins, only one will login at a time, and when a admin logs in, it will simply work whether it's first admin or the 1000th admin. If that's your question. If not please be more clear with your question. Thank you for watching my videos.
@@appwritersThankyou for replying. In my app, there is an Auditorium booking system, VC Appointment System, and Cafe Details
.
Now the above three system handle by three different users means when someone wants to meet VC he can request to the VC Personal assistant that I want an appointment the assistant send a message to the user that your appointment is fixed. Similarly, for Auditorium booking and the Cafe manager add the items so the user can see the items and price of food now I want to show auditorium admin to his page and for VC admin and cafe manager so how would I do that.
Hey brother,
Just watched the video and looks like I manually had to provide the role .
Is there any way to differentiate user like normal user and admin at the time of authentication like by adding another screen where I can ask user about role and authenticate it with some kind of pass/code ,I had use google auth for this . Is it possible? If yes then how ?
Or Is there better way to do that ?
@Netesh Paudel
Did u got d solution for that
@@mpr2801 no brother
if I log out and then log in with a admin account i get to the non-admin home page
Compare you code to the Code in the Repo linked in the Description.
if i just want hide some widgets in home page just for users how can i do it? thanks for the video !!
u can use visibilty widget and its has Visiblity{child:container(),visiblity:user.isAdmin = = true ?true : false;}
You can simply do these with conditionals (if or ternary operator by checking on the value of user or any other field that you want to base the visibility on)
@@appwriters sir , in app coin banauda nepal ma legal xa just for internal app transaction only
@@nepalicloud If that coin is only in APP and doesn't translate to real world physical cash, I think it's safe from any legal obligations of Nepal government.
@@nepalicloud It should basically be like reward points ?
want to show all admin list in user's home page.
It's just querying the Users collection and displaying the list
do you have any video on cloud firestore, refrerece data type
Sorry, not yet. Might be a nice addition.
@@appwriters If u could explain it, it'd be helpful, coz there aren't many explanatory videos on that, the way you do, Love from Maharashtra ❤️
cuntinue ;)
How to handle it. Can you give me some guideline please I need this?
Multiple if-else or switch statement
You can't handle it.
@@ExtraServingsBTS then what to do
@@urdupuzzle9438 start by watching 'A Few Good Men'
Great tutorial, thank you.
Glad you enjoyed it!
🔥♥️
you from Nepal bro ?
Yes! Why bro?
@@appwriters i was just wondering on your name so
thanks a lot man. You saved me.
Awesome! good to hear!