我正在构建一个带有firebase-auth和firebase-ui-auth的Android应用程序,用于Firestore中的身份验证和数据验证。我想有一些功能只对管理员用户可用,所以我需要实现某种基于角色的访问控制。我未能在Firebase文档中找到任何示例。但我找到了。它描述了在firebase-admin库中找到的功能。
我刚刚将我的Firebase库更新为15.0.0,但是firebase-admin目前仅在5.9.0版本上,并且不会在Android中加载,因为我得到了以下错误:
All firebase libraries must be either above or belo
我在我的Firebase数据库中有一个adminContent节点,只有当用户将admin设置为true作为自定义声明时,它才应该是可读/写访问的。
下面的代码显示,我的一个测试用户将admin设置为true作为声明,而另一个测试用户没有(因此问题似乎没有正确设置声明):
/* Check if admin */
firebase.auth().currentUser.getIdTokenResult().then(function(idTokenResult) {
if (idTokenResult.claims.admin) {
// THIS PART IS EXECUTE
我正在注册为第一个用户。
如何将管理员角色仅添加到Firebase Firestore数据库中的第一个用户?
const auth = firebase.auth();
const db = firebase.firestore();
// sign up the user
auth.createUserWithEmailAndPassword(email, password).then((cred) => {
// set admin to true for the only first user
return db.collecti
如果没有delete/override (旧变量),Firebase是否有像{ merge: true }这样的技巧来设置额外的/更多的自定义声明?
复制的步骤:
admin.auth().setCustomUserClaims(uid, { a: 'value' }) // Run this first
admin.auth().setCustomUserClaims(uid, { b: 'value' }) // Then run this after
结果:
{ b: 'value'}
预期结果
{ a: 'value',
我正在尝试使用javascript和防火墙创建一个登录名作为后端函数。我的代码似乎没有执行查询,而且firebase提供的用户id也没有从云中提取出来。我当前的代码只是将任何用户重定向到patientDashboard.php,而不管他们的“职业”如何。
这是我的密码
(function(){//initialize the firebase app
var config = {
};
firebase.initializeApp(config);
var auth = null;
var loginBtn= doc