我正在使用firebase身份验证,我引用此link
"users": {
".read": "auth != null && root.child('admins').child(auth.uid).val() == true",
".write": "auth != null && (root.child('admins').child(auth.uid).val() == true)",
"$uid": {
".read": "auth != null && (auth.uid == $uid || root.child('admins').child(auth.uid).val() == true)",
".write": "auth != null && (auth.uid == $uid || root.child('admins').child(auth.uid).val() == true)"
}
},
这是我的firebase用户表规则。
我的services.js
signupUser: function(newUser) {
var secondaryApp = firebase.initializeApp(FirebaseAppConfig, "Secondary");
var usersRef = firebase.database().ref().child('users');
return secondaryApp.auth()
.createUserWithEmailAndPassword(newUser.email, newUser.password)
.then(function(firebaseUser) {
secondaryApp.auth().signOut();
var newUserWithoutPwd = _.extend({}, newUser);
delete newUserWithoutPwd.password;
return usersRef
.child(firebaseUser.uid)
.set(newUserWithoutPwd)
.then(function() {
return newUserWithoutPwd;
});
});
},
认证成功。但用户表显示权限被拒绝错误。
显示以下屏幕截图
答案 0 :(得分:3)
我的猜测是您希望新创建的用户将其用户配置文件写入数据库。在这种情况下,重要的是:
firebase.database(secondaryApp).ref().child('users')
在代码中:
signupUser: function(newUser) {
var secondaryApp = firebase.initializeApp(FirebaseAppConfig, "Secondary");
var usersRef = secondaryApp.database().ref().child('users');
return secondaryApp.auth()
.createUserWithEmailAndPassword(newUser.email, newUser.password)
.then(function(firebaseUser) {
var newUserWithoutPwd = _.extend({}, newUser);
delete newUserWithoutPwd.password;
return usersRef
.child(firebaseUser.uid)
.set(newUserWithoutPwd)
.then(function() {
secondaryApp.auth().signOut();
return newUserWithoutPwd;
});
});
},
答案 1 :(得分:1)
return firebase.database(secondaryApp).ref().child('users')
更新此signupUser: function(newUser) {
var secondaryApp = firebase.initializeApp(FirebaseAppConfig, "Secondary");
return secondaryApp.auth()
.createUserWithEmailAndPassword(newUserInsert.email, newUserInsert.password)
.then(function(firebaseUser) {
var newUserWithoutPwd = _.extend({}, newUserInsert);
delete newUserWithoutPwd.password;
return firebase.database(secondaryApp).ref().child('users')
.child(firebaseUser.uid)
.set(newUserWithoutPwd)
.then(function() {
return newUserWithoutPwd;
});
});
},
。
QString myRequest = "CREATE DATABASE MY_DATABASE;";
lQueryResult.Exec(myRequest);
if(!lQueryResult.GetMexec())
{
qDebug() << "Error in the request";
return false;
}
else
{
qDebug() << "The request is OK";
}