Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要javascript中firestore的帮助吗_Javascript_Firebase Authentication - Fatal编程技术网

需要javascript中firestore的帮助吗

需要javascript中firestore的帮助吗,javascript,firebase-authentication,Javascript,Firebase Authentication,我想获取新创建的用户的用户id,这样我就可以将我的文档命名为该uid,但它显示为null 这是我的密码 addDriver(){ var $this = this secondaryApp.auth().createUserWithEmailAndPassword($this.driver.email, $this.driver.password).then(function(user){ $this.$db.collection("driver").doc(us

我想获取新创建的用户的用户id,这样我就可以将我的文档命名为该uid,但它显示为null

这是我的密码

addDriver(){
    var $this = this
    secondaryApp.auth().createUserWithEmailAndPassword($this.driver.email, $this.driver.password).then(function(user){
        $this.$db.collection("driver").doc(user.uid)
            .set({
                fname: $this.driver.fname,
                lname: $this.driver.lname,
                contact_number: $this.driver.cnum,
                license_number: $this.driver.license,
                email: $this.driver.email,
                password: $this.driver.password,
            })
            secondaryApp.auth().signOut();
        $this.formHeaderStatus = $this.$db.auth().currentUser
    })
},

还有,我这样做对吗?因为我是以管理员身份登录的?我想在不注销自己的情况下创建一个新用户。

我不完全确定,但我相信问题在于使用createUserWithEmailAndPassword返回的承诺时

从我收集的信息来看,应该是这样的:

addDriver(){
var$this=this
secondaryApp.auth().createUserWithEmailAndPassword($this.driver.email,$this.driver.password)。然后(函数(**data**){
$this.$db.collection(“driver”).doc(**data.user.uid**)
.设置({
fname:$this.driver.fname,
lname:$this.driver.lname,
联系电话:$this.driver.cnum,
许可证号码:$this.driver.license,
电子邮件:$this.driver.email,
密码:$this.driver.password,
})
secondaryApp.auth().signOut();
$this.formHeaderStatus=$this.$db.auth().currentUser
})

},
在客户端Firebase身份验证SDK中创建新用户帐户时,必须先登录该用户。而且一次只能登录一个用户,因此这将自动注销现有用户。客户端SDK没有“管理员”的概念。对于这样的管理功能,您应该在受信任的环境(例如您的开发机器、您控制的服务器或云功能)中使用AdminSDK。请看我的答案:你似乎已经在做我链接的答案中建议的事情了。请把你的问题放在最低限度,因为这让我们能够关注你真正需要的东西(我在下面回答了)。哦。。真见鬼。帮了大忙。我以为你可以把任何东西放进去。然后(var)的东西,它现在可以工作了!谢谢你