How to authorize certain pages to different users in flutter [closed] - firebase

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
We got assigned to make event-management (Creating College Events with Firebase) application in flutter. Work we did: Creating Event (form) and returning an event card (containing event details in brief) in Homescreen. But we were told to make different pages for certain users like admin and student coordinators who can only create an event. While users can view event only. With the help of what can we do this?
Is there any library in flutter which we are unaware of?
Do we have to make another layout for admins and another for coordinator and other for users and then connect them?

You can give different levels of authorization to different people.
Maintain a users collection in your Firebase database
For each user, create a document. You might already be storing details like name, uid, email, etc. In addition to that, maintain a string field level.
Upon login, check user's level. For instance, if the level==student you can display on your homepage only the button that will lead to event_list_page.dart.
If level==admin, also display a button tocreate_event_page.dart.
How will you assign the level?
If there are only a handful (5-6) admins, manually edit their tag in Firebase console.
(Assuming email auth) Otherwise, you will have to create a list of email ids of admins, in advance. Then you can simply run a script using Firebase Admin SDK to fetch the user documents of admins from your users collection in database.
If you don't want to use Firebase Admin SDK, you can also write some code in Flutter itself to fetch admin documents and update their tag.

Related

How can I have different types of users in one app in firebase? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 months ago.
Improve this question
I am trying to use firebase to build an e-commerce application. In the application, there will be normal customers that can buy items from a store. A store will have its own page where there will be a list of all the products that the store is selling. However, some people own multiple stores, so I want to be able to create a way for them to have an overview of all their stores too. For example, a customer named John can buy a product from a store named 'John's Electronics store'. John is a business owner that owns 'John's Electronics' and 'John's Sporting Goods'. John has managers at each store that should be able to handle the store's account, but John should be able to grant and revoke access for the managers.
Is there a name for this sort of architecture? I am unsure of the best way to model the data and permissions. I am building this application with Firebase's Cloud Firestore. I have thought of using custom claims. Any advice on how to go about doing this would be greatly appreciated as I am a beginner with this stuff.
What you're looking for is role-based access control, and it is described in the Firebase documentation on security rules here and in this video: Implementing Authorization Models.
Here on Stack Overflow, I also recommend looking at:
What is the best way to authenticate two types of users (Student and Driver) in my android app using Firebase
Firebase Auth signIn distinction
Multiple role authentication Firebase Web
firebase security rule to allow admin users to read/write all other users creates a security breach?
I need to create 3 types of users
Firebase Auth with different user types

How to store user-specific documents in firebase? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm using Flutter and Firebase Firestore to build a note-taking app. I'm trying to store each new note under the signed-in user in Firestore but the notes are visible to all users.
If you have the time, I suggest you watch this fully. It explains clearly and precisely how to make a Note making app with a clean architecture.
Reso Coder's DDD
But, if you just want to get to the firebase security rules and the implementation, then see this:
Create, Update, Delete Notes
and
Firebase Security Rules.
You might wanna see this to get the updated code after firebase's update in flutter.
You can make Collections using the unique user-ID given by Firebase at the time of Registering User!
you can get the user-ID of the current user by executing FirebaseAuth.instance.currentUser.uid
and store the notes as Documents in specific user's Collection.
At the time of Retrieval you can use the Stream Builder and give the Stream as collection of Current User's user-ID.

Is it possible to create users inside a logged in user [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hi I have an app where it have user and admin. So i have defined my role in firestore and based on the app i have fetched the pages. Here both user and admin can login to same app but in profile functions there is a function for manage pages this is where i have used the role based access.
In admin page i tried created new users with FirebaseAuth.instance.createuserwithemailandpassword (). When it creates it has to be added to a listview. But when i add a new user through bottom sheet it passes the created user uid and shows details for created users. But what i require is the details to be remained same when logged in not after creating the user?
Would it he possible or is there a way for doing it?
When you create a new user in Firebase with a client-side SDK, it replaces any user that is currently signed in. That is the expected behavior, as the client-side SDKs are not meant for administrative activities like what you're describing.
If you want to have an application administrator who can create accounts for other users, consider creating a custom backend API for them, where you then use the Admin SDK to create the account(s). This also makes it much less likely that you're run into issues with the quota for creating accounts from a single IP.
Also see:
Firebase kicks out current user
How to create firebase admin user for authentication in java (which has links to many more similr questions)
How to create an Admin module for managing Firebase users access and roles

Implementing ADD friends feture in flutter app like in instagram, snapchat, faceboook [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i am currently working on a flutter app which is kinda social media app, right now i am stuck with the idea to implement the add friends feature from a list of contacts who have account in my app, but i can not think of any method of doing so , my app's back-end is handled by Firebase with each user's profile information stored differently in Firestore database,
i want a simple and efficient way to add friends in my app, more like Facebook, Instagram, Snapchat,
can anyone suggest me how to implement this feature in my app?
if so please provide links to pages and documentations!
Thank you
There are lots of ways this could be achieved, one is creating a collection Users and each document per user, inside that user document you will have two Lists of user ids 1. friends 2. requests ... so when someone sends a request, add the sender's user-id into requests section inside the receiver's user document, when the user accepts the request delete the user id from the requests and add sender's user-id into friends list.
Root => Users(collection) => userid1(document) => friends(List<String>)
=> requests(List<String>)
This is just one way do your research and use what's appropriate for you. :)

How can I implement an invitation system using Flutter and Firebase realtime database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am developing a Flutter app that is using the firebase realtime database. The app shall be used collaboratively by users to collect and analyze data. Users are part of a team and the data that is collected will be associated with the team. For a user to join a team, they are required to use an invitation link that is sent out by the team leader. The invite shall use the teamId which is a unique identifier for each team.
How could I go about this.
It sounds like you have a two-step process:
Create a link for a specific team that the user can click to then get into the app as part of the team.
Sending that link to the user.
For that type of link you can use Firebase Dynamic Links, for which a Flutter wrapper exists: firebase_dynamic_links plugin.
For sending the link you have many options, but the most common ones are to send it through email or SMS/text message. When the user then clicks the link, it can open your app, and you can extract information about the team from the link.
If the target user is already using your app, you can of course skip all this and create a notification system through the Realtime Database. There's nothing pre-made for that, but it's just more use of the APIs you're already using.

Resources