javascript - 从同一设备进行第二次注册尝试时未执行 Firestore 写入操作
问题描述
所以我整天都在做这个,我仍然无法弄清楚或在网上找到任何帮助。我很确定这是我想念的非常小的东西。我会尽力解释我的问题。
我有一个带有 Firestore 和 Firebase-Authentication 的 Vue.js SPA。今天我注意到我的应用程序出现了一些奇怪的行为,我认为这与缓存有关。所以我有 SignUp 组件,其中有以下内容:
firebase
.auth()
.createUserWithEmailAndPassword(this.email, this.password)
.then(
function(user) {
firebase
.firestore()
.collection("users")
.doc(user.user.uid)
.set({
firstname: _this.fName,
lastname: _this.lName,
username: _this.uName,
email: user.user.email
})
.then(() => {
_this.$store.commit('setCurrentUser', {email: user.user.email, uid: user.user.uid})
_this.$router.replace("/HomeUserPage");
})
.catch(function(error) {
console.log("Error signing up:", error);
});
},
function(err) {
console.log(err.message, "this is an error");
}
)
我在另一个组件中也有这样的 SignOut 处理程序:
firebase
.auth()
.signOut()
.then(() => {
this.$router.replace("Login");
})
.catch(function(error) {
console.log(error);
});
我的问题如下:每当我注销并尝试创建一个新用户(注册)时,它第一次就完美了。然后我注销,并尝试再注册一个用户,现在发生的事情是我创建了用户,但是,在 .createUserWithEmailAndPassword 的回调中对 firestore 数据库的调用没有执行,因此,我的路线没有改变而且我的数据没有被填充。
到目前为止我发现了什么:如果我在注销后重新加载页面就不会发生这种情况(因此,为什么我认为问题来自缓存)。
您有什么想法为什么会发生这种情况,这是预期的行为吗?我只是希望在每次注销后重新加载页面?
解决方案
好吧,我想通了。显然,这是 Doug 上面提到的一个错误,所以我去 Github 上发布它,并且已经报告了它:
https://github.com/firebase/firebase-js-sdk/issues/3218
这是旧版本(7.15)中的一个问题,现在已修复(7.16)。所以刚刚更新了我的 Firebase SDK,现在一切都按预期工作了。
推荐阅读
- haskell - Haskell,使用用户输入创建列表
- php - 将 curl 翻译成 CakePHP 3.6 httpclient?
- ruby - 在 ruby 上解析日志文件
- printing - Gtk:我如何预设/恢复选定的打印机?
- git - IntelliJ Idea gpg 未能签署数据
- ios - 将动画添加到视图
- distributed-computing - 我可以使用 Mesos 预留间接资源吗?
- javascript - 当我尝试将 google place 自动完成 API 与 Axios 一起使用时出现 CORS 错误
- javascript - 如何使用 node .js 将 html 的值表添加到 mysql
- c# - 如何将日期列表与实体中的数据库表连接起来?