注册新用户时,polymerfire会注销当前用户 [英] polymerfire logs out current user when a new user is registered

查看:72
本文介绍了注册新用户时,polymerfire会注销当前用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Polymer 1.0应用程序中有一个admin部分,它使admin用户可以创建其他新用户.但是,一旦注册了新用户,管理员用户就会注销,新用户也将登录.我正在使用polymerfire元素<firebase-app><firebase-auth>来执行此操作,有没有一种方法可以保留管理员用户在登录时仍在注册新用户?

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?

推荐答案

我阅读了对类似的非答案聚合物问题使我想到了一个简单的解决方案.只需在应用程序中添加第二个<firebase-app>,并为其指定一个与主<firebase-app>不同的名称,并在创建新用户时引用该名称:

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>

请注意,除了名称之外,两个<firebase-app>实例的所有配置属性都相同.这样会将第二个实例连接到同一Firebase项目并注册新用户,而不会影响管理员的实例.

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.

这篇关于注册新用户时,polymerfire会注销当前用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆