Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: Implementing Switch / Add Account Features

I am working on Firebase application ( Firebase version 4.1.3 )

My health care related application is made for dependent group of people such as children and seniors. However, most of my users are independent group of people age around 18-55. Most of my users use my application for their seniors/children. They need to create account for each of their family seniors/children member. Therefore, my users have to log in and out many times and they have to keep track of their family members' account. My first thought was I should make an account switching feature so that my user can switch their account back and forth between their family members to update information on my application.

After searches on Google, I found way to force switching account on Firebase authentication with Google provider, but those are not what I'm looking for.

My questions are:

  • Is it possible to store the multiple firebase auth objects (logged in object) in client side?

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

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

like image 670
pupuupup Avatar asked Nov 18 '22 15:11

pupuupup


1 Answers

The functionality you are asking for is not available out of the box. You have to build it on your own. I do think Firebase provides the pieces to allow you to build it (via Auth and Database).

  1. Is it possible to store the multiple firebase auth objects (logged in object) in client side: You can have multiple Firebase app instances and each one have an auth instance with a current user. You would need to ask each user to authenticate though (you can't authenticate once and sign-in into all of the account). However, you can build your own user group login mechanism, where logging in with one "master" account can allow you to login with multiple accounts using custom Auth.

  2. If it is possible, for how long will the token inside the firebase auth object last for. Firebase sessions are supposed to be indefinite. If a token expires (typically after one hour), it can be refreshed automatically if you are using real time database.

like image 82
bojeil Avatar answered Jan 18 '23 22:01

bojeil