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

ความคิดเห็น • 99

  • @snoligroup
    @snoligroup ปีที่แล้ว

    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

  • @kikalamuofficial5865
    @kikalamuofficial5865 2 ปีที่แล้ว

    Thank you been looking for this ❤️

  • @enriqueglopezsanchez
    @enriqueglopezsanchez 4 ปีที่แล้ว +1

    Thank you. Very good video

  • @richpo9814
    @richpo9814 3 ปีที่แล้ว

    Firebase Auth made updates for October. There were lots of changes made. Firebase Auth and User. Dart now conflicts with eachother when importing.

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      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

    • @dileepdilraj5254
      @dileepdilraj5254 3 ปีที่แล้ว

      Read documents in official flutter website there are very few commands only changed and that more easy access commands

  • @Bl4kRobbie53
    @Bl4kRobbie53 3 ปีที่แล้ว +4

    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

  • @ahmedtarek8676
    @ahmedtarek8676 4 ปีที่แล้ว +1

    thank you
    you are the best

  • @SeyyedNaquibAlFaruqi-ACS
    @SeyyedNaquibAlFaruqi-ACS 3 ปีที่แล้ว

    thanks a lot man. You saved me.

  • @swayamshreemohantyvlogs8126
    @swayamshreemohantyvlogs8126 2 ปีที่แล้ว

    Thanks man you are just awesome..

  • @tobiasmiklavcic2211
    @tobiasmiklavcic2211 3 ปีที่แล้ว +1

    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'].

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      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.

    • @mpr2801
      @mpr2801 3 ปีที่แล้ว

      Have u corrected your error
      Even i am.getting d same error

    • @mpr2801
      @mpr2801 3 ปีที่แล้ว

      @@appwriters
      What are the changes that we need to make if we get the above error

    • @jimbansuela6515
      @jimbansuela6515 2 ปีที่แล้ว +1

      hey if you are still having this error just remove the " .data()" in "snapshot.data.data()"

  • @pulscare6272
    @pulscare6272 3 ปีที่แล้ว

    you are love. solved my big problem. ThankYou soo much.. how to save "name" in database throuh signup

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      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.

    • @pulscare6272
      @pulscare6272 3 ปีที่แล้ว

      @@appwriters Thankyou.

    • @adnankitabi9530
      @adnankitabi9530 3 ปีที่แล้ว

      @@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

  • @WikkiOnIlluminati
    @WikkiOnIlluminati 2 ปีที่แล้ว

    Could you please update the description of this video to show timestamps for chapters of your video?

  • @luzgenesis7
    @luzgenesis7 3 ปีที่แล้ว +1

    I have a problem in a main.dart when i logged =>
    " The method '[]' was called on null.
    Receiver: null
    Tried calling: []("role") "

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Compare you code with the code in the github repository.

    • @doctork2579
      @doctork2579 3 ปีที่แล้ว +2

      did u got the solution ? please help because i stack to this also

    • @luzgenesis7
      @luzgenesis7 3 ปีที่แล้ว

      @@doctork2579 tell me if it works for you

    • @emirhan6134
      @emirhan6134 3 ปีที่แล้ว

      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.

    • @paulinezipagan2136
      @paulinezipagan2136 ปีที่แล้ว

      upp! can someone help? what's the solution for this?

  • @jayamuruganj5091
    @jayamuruganj5091 3 ปีที่แล้ว

    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

  • @alanoodalmaari8106
    @alanoodalmaari8106 3 ปีที่แล้ว

    When I press on login it does not take me to the another page still in log in page

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      You should please compare your code to the code in the repository!

  • @kobbydiscount2635
    @kobbydiscount2635 3 ปีที่แล้ว

    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

  • @user-tf7te9kr8w
    @user-tf7te9kr8w 4 ปีที่แล้ว

    Very thank's

  • @anugrahkorambeth431
    @anugrahkorambeth431 3 ปีที่แล้ว

    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?

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      If you apply the same role based checking as well in the Firestore Security rules, then there should not be any security issue.

  • @Yusuf-rh6sj
    @Yusuf-rh6sj 3 ปีที่แล้ว

    Thx from Turkey

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Thank you too! for your support

    •  3 ปีที่แล้ว +1

      oo topram

  • @leoncoors5734
    @leoncoors5734 3 ปีที่แล้ว

    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?

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      Best implement some state management to do it properly. Check my flutter firebase starter ( github.com/lohanidamodar/flutter_firebase_starter )

  • @jayamuruganj5091
    @jayamuruganj5091 3 ปีที่แล้ว

    pls make the video for the admin only create the users

  • @leoncoors5734
    @leoncoors5734 3 ปีที่แล้ว

    Good video brother

  • @jcperez7925
    @jcperez7925 2 ปีที่แล้ว

    is there an updated version of this video?

    • @appwriters
      @appwriters  2 ปีที่แล้ว

      Sorry, no, but most of the concepts should work in any version

  • @victorlongoro4574
    @victorlongoro4574 3 ปีที่แล้ว

    hellow sir , can you make a video using using getx with role based, its bit challenge out here

  • @sgouri3519
    @sgouri3519 3 ปีที่แล้ว

    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

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      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

  • @akshaybhadauria4765
    @akshaybhadauria4765 2 ปีที่แล้ว

    Can you please make a video on role based using react and firestore

    • @appwriters
      @appwriters  2 ปีที่แล้ว

      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

  • @urdupuzzle9438
    @urdupuzzle9438 3 ปีที่แล้ว

    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.'

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      That means they all are not same admin, they all have different role, so you have to handle separately.

    • @urdupuzzle9438
      @urdupuzzle9438 3 ปีที่แล้ว

      @@appwriters How to handle it. Can you give me some guideline please I need this?

    • @1stplace362
      @1stplace362 2 ปีที่แล้ว

      bro did you find a solution

    • @urdupuzzle9438
      @urdupuzzle9438 2 ปีที่แล้ว

      @@1stplace362 no

  • @basspalace2920
    @basspalace2920 3 ปีที่แล้ว

    Yo......you look like a bald Tekashi69.....dope tutorial though. I definitely needed this.

  • @urdupuzzle9438
    @urdupuzzle9438 3 ปีที่แล้ว

    how to assign multiple roles like if there is more than one admin then we should use else if or something else??

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      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).

    • @urdupuzzle9438
      @urdupuzzle9438 3 ปีที่แล้ว

      @@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

  • @amitbairwa7016
    @amitbairwa7016 3 ปีที่แล้ว

    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?

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      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.

    • @amitbairwa7016
      @amitbairwa7016 3 ปีที่แล้ว +1

      @@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.

  • @gaspargiddson5060
    @gaspargiddson5060 3 ปีที่แล้ว

    how can i add name on my Map data

  • @pulscare6272
    @pulscare6272 3 ปีที่แล้ว

    if i want show all admin in user_home_page.. what code should i write for this??

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      I am not sure I understand your question?

    • @pulscare6272
      @pulscare6272 3 ปีที่แล้ว

      @@appwriters want to show all admin list in user's home page.

  • @urdupuzzle9438
    @urdupuzzle9438 3 ปีที่แล้ว

    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

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      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.

    • @urdupuzzle9438
      @urdupuzzle9438 3 ปีที่แล้ว

      @@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.

  • @neteshpaudel724
    @neteshpaudel724 3 ปีที่แล้ว

    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 ?

    • @mpr2801
      @mpr2801 3 ปีที่แล้ว

      @Netesh Paudel
      Did u got d solution for that

    • @neteshpaudel724
      @neteshpaudel724 3 ปีที่แล้ว

      @@mpr2801 no brother

  • @eduardomelato5147
    @eduardomelato5147 3 ปีที่แล้ว

    if I log out and then log in with a admin account i get to the non-admin home page

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Compare you code to the Code in the Repo linked in the Description.

  • @luzgenesis7
    @luzgenesis7 3 ปีที่แล้ว

    if i just want hide some widgets in home page just for users how can i do it? thanks for the video !!

    • @nepalicloud
      @nepalicloud 3 ปีที่แล้ว

      u can use visibilty widget and its has Visiblity{child:container(),visiblity:user.isAdmin = = true ?true : false;}

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      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)

    • @nepalicloud
      @nepalicloud 3 ปีที่แล้ว

      @@appwriters sir , in app coin banauda nepal ma legal xa just for internal app transaction only

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      @@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.

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      @@nepalicloud It should basically be like reward points ?

  • @pulscare6272
    @pulscare6272 3 ปีที่แล้ว

    want to show all admin list in user's home page.

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      It's just querying the Users collection and displaying the list

  • @danishdarren1179
    @danishdarren1179 3 ปีที่แล้ว

    do you have any video on cloud firestore, refrerece data type

    • @appwriters
      @appwriters  3 ปีที่แล้ว +1

      Sorry, not yet. Might be a nice addition.

    • @danishdarren1179
      @danishdarren1179 3 ปีที่แล้ว +1

      @@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 ❤️

  • @Dima-qz4su
    @Dima-qz4su 2 ปีที่แล้ว +1

    cuntinue ;)

  • @urdupuzzle9438
    @urdupuzzle9438 3 ปีที่แล้ว

    How to handle it. Can you give me some guideline please I need this?

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Multiple if-else or switch statement

    • @ExtraServingsBTS
      @ExtraServingsBTS 3 ปีที่แล้ว

      You can't handle it.

    • @urdupuzzle9438
      @urdupuzzle9438 3 ปีที่แล้ว

      @@ExtraServingsBTS then what to do

    • @ExtraServingsBTS
      @ExtraServingsBTS 3 ปีที่แล้ว

      @@urdupuzzle9438 start by watching 'A Few Good Men'

  • @vongphetphongsavath2477
    @vongphetphongsavath2477 3 ปีที่แล้ว

    Great tutorial, thank you.

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Glad you enjoyed it!

  • @ravikovind
    @ravikovind 4 ปีที่แล้ว

    🔥♥️

  • @roshanjungkunwar8440
    @roshanjungkunwar8440 4 ปีที่แล้ว

    you from Nepal bro ?

  • @leloughlemperough1903
    @leloughlemperough1903 3 ปีที่แล้ว

    thanks a lot man. You saved me.

    • @appwriters
      @appwriters  3 ปีที่แล้ว

      Awesome! good to hear!