polymerfire logs out current user when a new user is registered

二次信任 提交于 2019-12-11 17:55:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/46698800/polymerfire-logs-out-current-user-when-a-new-user-is-registered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!