I have an admin section in my Polymer 1.0 app that gives admin users the ability to create other new users. However, as soon as the new user is registered the admin user is logged out and the new user is logged in. I'm using the polymerfire
elements <firebase-app>
and <firebase-auth>
to do this, is there a way to keep the admin user logged in while still registering a new user?
Asked
Active
Viewed 154 times
0

Evan Caldwell
- 153
- 2
- 14
1 Answers
0
I read this answer to a similar non-polymer question which led me to a simple solution. Just add a second <firebase-app>
to the app, give it a different name than your main <firebase-app>
and reference that when you create the new user:
<firebase-app name="main-fb-app"
auth-domain="someapp.firebaseapp.com"
database-url="https://someapp.firebaseio.com"
api-key="crazykey"
storageBucket="someapp.appspot.com"
messagingSenderId="someid"></firebase-app>
<!-- need a secondary app element for registering new members without logging out the current user -->
<firebase-app name="reg-member"
auth-domain="someapp.firebaseapp.com"
database-url="https://someapp.firebaseio.com"
api-key="crazykey"></firebase-app>
Then where you want to use it:
<firebase-auth id="newUserAuth"
app-name="reg-member"
user="{{member}}"
provider="password"
status-known="{{memberStatusKnown}}"
signed-in={{memberSingedIn}}
on-error="_handleError"></firebase-auth>
Notice all the config attributes are the same for both <firebase-app>
instances except the name. This will connect a second instance to the same Firebase project and register the new user without affecting the admin's instance.

Evan Caldwell
- 153
- 2
- 14