【发布时间】:2021-10-04 00:36:46
【问题描述】:
我正在制作一个聊天应用程序,并且我正在使用 firebase 进行身份验证。目前,允许两个或多个用户拥有相同的用户名 (displayName)。我想添加验证以防止这种情况。以下是注册功能。我正在使用 Vue.js,但对于非 Vue 用户来说也应该很容易理解。
methods: {
signup(e) {
e.preventDefault();
firebase
.auth()
.createUserWithEmailAndPassword(this.email, this.password)
.then((result) => {
result.user.updateProfile({
displayName: this.username,
});
this.email = "";
this.password = "";
this.$emit("closemodal");
})
.catch((error) => {
this.error = error.message;
});
},
},
提前谢谢你。
【问题讨论】:
标签: javascript firebase vue.js authentication firebase-authentication