【问题标题】:Сan’t create a user in the Firebase Database无法在 Firebase 数据库中创建用户
【发布时间】:2020-10-02 05:01:26
【问题描述】:

无法在 Firebase 数据库中创建用户请帮助或 告诉我有关此问题的文档。 是不是笔画user_id: cred.user.uid ?

  methods: {
    signup(){
      if(this.alias && this.email && this.password){
        this.feedback = null
        this.slug = slugify(this.alias, {
          replacement: '-',
          remove: /[$*_+~.()'"!\-:@]/g,
          lower: true
        })
        let ref = db.collection('users').doc(this.slug)
        ref.get().then(doc => {
          if(doc.exists){
            this.feedback = 'This alias already exists'
          } else {
          // this alias does not yet exists in the db
            firebase.auth().createUserWithEmailAndPassword(this.email, this.password)
            .then(cred => {
              ref.set({

                alias: this.alias,
                geolocation: null,
                user_id: cred.user.uid
              })
            }).then(() => {
              this.$router.push({ name: 'GMap' })
            })
            .catch(err => {
              this.feedback = err.message
            })
          }
        })
      } else {
        this.feedback = 'Please fill in all fields'
      }
    }
  }

【问题讨论】:

  • 你必须测试它,console.log(cred) 如果我是,我会为我要添加到数据库中的信息创建一个新函数,这样使用它是不好的。例如 saveUserDatabase({this.alias,null,cred.user.uid})
  • 看起来是正确的。 devtools 控制台中是否有任何错误消息?
  • 否,但未创建数据库(

标签: javascript node.js firebase vue.js google-cloud-firestore


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-10-16
  • 2016-11-03
  • 1970-01-01
  • 2021-12-02
  • 2019-11-09
  • 1970-01-01
  • 2017-12-26
相关资源
最近更新 更多