Firebase: Implementing Switch / Add Account Features

I am working on a Firebase app (Firebase version 4.1.3)

My healthcare app is made for an addicted group of people like kids and seniors. However, most of my users are an independent group of people aged 18-55. Most of my users use my app for their seniors / kids. They need to create an account for each of their family members / children. So my users have to register and log out multiple times and they have to keep track of their family members' account. My first thought was that I had to enable the account switching feature so that my user could switch their account between their family members to update my app information.

After searching on Google, I found a way to force the account to switch to Firebase authentication using the Google provider, but that's not what I'm looking for.

My questions:

  • Is it possible to persist client side multiple firebase objects (registered object)?

  • If possible, how long will the token last inside the auth firebase object?

  • If it doesn't last forever, is it possible to update the token refresh so that it can be used without re-authenticating with social / phone login?

+3


source to share


2 answers


I don't think Firebase has this token ability. But you can just put the email address of people on the device using general settings (for Android). When a user wants to log in with that user, enter their email address, just ask them for a password, and then go through the registration process.
If you don't want to use SharedPreferences, you can simply save the users (just like you said family members) to the Firebase database and associate them with the controller user, so to speak. Whenever a user wants to switch, go in and fetch other family members' email addresses from the Firebase database and ask the customer for a password and authorize with Firebase Authentication.
Hope it helps!



0


source


The requested feature is not available out of the box. You have to build it yourself. I think Firebase provides parts that will allow you to build it (via Auth and Database).



  • Is it possible to store objects with multiple firebase objects (registered object) on the client side: you can have multiple instances of the Firebase app and each one has an auth instance with the current user. You will need to ask each user to authenticate (you cannot authenticate once and log into all accounts). However, you can create your own user group logon mechanism where logging in with one "master" account will allow you to log in with multiple accounts using a custom Auth.

  • If possible, how long will the token last inside the auth firebase object. Firebase sessions must be undefined. If the token expires (usually after one hour), it can be refreshed automatically if you are using a live database.

0


source







All Articles