Connect to multiple accounts - android

I am planning to make a locator app in android java language. What I want to know is, how can I connect multiple accounts to the main/admin account so that I can track them? I want to have the options of adding the other accounts through sending digit codes to the email address and phone number.
I want to know what specific classes, libraries or any other ways needed for that.
Thank you....

If you're using Firebase's Firestore then simply add the user's Uid to admins document in a String array considering that you have a structure like Users (collection) > Uid (document).
Similarly, every user should have a unique code that can be sent from admin to the user that has to be added and a mechanism to prevent unknown users from getting added to admins location array.

Related

Is there any way to give access to particular node to some user without authentication?

My firebase database looks like below:
Suppose I have 50 users and I want to give access to node code-1 to user 1-20, code-2 to user 21-40 and code-3 to user 41-50. I have some problem and I don't want to use firebase authentication. Is there any way to do so? like sending data from user to firebase and then complete checking in Realtime database rules section and then grant permission.
Two options come to mind:
Security through obscurity: Rename code-1 to something unguessable like c17357345db9 and rename code-2 to 64af7b679319. Then share a link to an app that gives access to c17357345db9 to users 1-20, then share a different link for 64af7b679319 to users 21-40.
Create an API Server: Don't allow direct access to the RTDB but instead create a Cloud Function that acts as a REST API to retrieve the data based on the user's ID.
Neither are optimal and user 3 could easily share access with user 30 if they wanted to.

How do I receive the specific user data from firebase using phone number not by uid?

I have done phone authentication linked to my project but I am not pushing the data from android instead I have manually entered the user data in Firebase. And I want to retrieve the data from firebase using OTP verification and I just need to search the specific user data with phone number which I am entering while login. I want to show all fields to be displayed which are present in my firebase database into my android project.
I've tried many methods to receive the data but I am stuck... Please help me.
Database structure
Authentication panal
You need to logically bind your authenticated user and the data that you stored in your firebase. As per the image in your data base 'id' of the 'Users' are 1,2,.. like that. Instead of that you can use 'UID' of users as an an Id in your database. Go to your 'Authentication' section, you will see User UID against each registered user. Copy that and use as an ID while creating data in database. This will help you to get the data with reference like Users\. Hope this will solve your problem.

How to link already stored data to users in Firebase

I am creating an application that would allow users to access data on their phones. Examples would be progress scores/test results.
I can upload the data to Firebase with an email address as the user link.
Is there a way that I can link this already loaded data to a user (with the same email address) once they have registered? Ideally using the email address in a rule to search up that data and use that reference point in the app.
Ideally I would like to pre-upload the users in bulk, but I know that Firebase only allows one user to be added at a time.
Any help would be appreciated.
After a user sign in to the app through the Firebase auth you can get its email through this call:
FirebaseAuth.getInstance().getCurrentUser().getEmail()
If you want to import data into your database, you should first make a json out of your data (list of users by email) and then use Firebase-Import to put it in your datastore.

Is storing users' passwords in FirebaseDatabase is a good idea?

I am making an app, and in that app, users login and I am storing their information; however, I have noticed that I don't have a users' password information after they register. Is it a good idea to store users' password when they register through Firebase? And is there a point where I will need their passwords? I want to make sure before I proceed further. Thanks!
You do not do that.
Use the (awesome, amazing) Firebase authentication system.
Click right here:
on the left, to see all the users - click "Authentication".
You never see / you cannot see their passwords.
You don't handle or touch the passwords at all.
In the Android or iOS app, you get the userid - and that's it.
The answer by #PeterHaddad shows perfectly how to do that.
That's the first and most basic step in any Firebase ios/droid app.
In your data you'll have a "table" called probably "userData/" and that's where you keep all data about the user. (For example, you may store their address, real name, shoe size .. whatever is relevant in your app.)
Note - FBase is so amazing, your users can also connect with other methods (phone, etc). For your reference in the future, that is explained here
You don't need to store the password in the firebase database, after you authenticate the user using createUserWithEmailAndPassword the email and other info will be stored in the authentication console. So you do not need the password in the database, all you need is the userid to connect auth with database.
FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
String useruid=user.getUid();

Android - How to manage multiples user levels and types

I have project be used by different group then user.
For example: one group is secretary user, another is the admin user, medical user.
Currently my code this so below:
if(App.getInstance().getCustomer().isAdmin())
replaceFragment(R.id.view_main,new AdminFragment);
if(App.getInstance().getCustomer().isMedical())
replaceFragment(R.id.view_main,new MedicalFragment);
My question is, what is the way more sophisticated to accomplish this control
Usually this sort of thing is done with a database. In websites you have different permission levels based on the type of user. A database can store information about users and when a user connects to the application, check what permissions they have.

Categories

Resources