- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将新注册的用户及其新创建的用户 UID 保存到数据库中。然而它返回未定义,我不知道为什么。这就是我所拥有的
function fb_signup(){
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function success(userData){
var uid = userData.uid;
var displayName = userData.displayName;
var email = userData.email;
var emailVerified = userData.emailVerified;
var photoURL = userData.photoURL;
var isAnonymous = userData.isAnonymous;
var providerData = userData.providerData;
$('#fbFormMessage').css({'display':'block','background-color':'#c9e9cc','color':'#347f3b'});
document.getElementById("fbFormMessage").innerHTML = 'Welcome Your registration was successful.';
console.log(uid + ' | ' + email + ' | ' + uName )
saveNewUser(uid, email, uName);
return false;
})
.catch(function failure(error) {
var errorCode = error.code;
var errorMessage = error.message;
console.log(errorCode + " " + errorMessage);
$('#fbFormMessage').css({'display':'block','background-color':'#FFEBEE','color':'#EF5350'});
document.getElementById("fbFormMessage").innerHTML = 'The email address is already in use by another account';
});
};
function saveNewUser(a,b,c){
console.log('4')
var rootRef = firebase.database().ref();
var storesRef = rootRef.child('/users/');
var newStoreRef = storesRef.push();
newStoreRef.set({
uid: a,
userName: c,
email: b,
});
};
最佳答案
因为 createUserWithEmailAndPassword()
方法返回 UserCredential
(而不是用户
),详见文档:https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword
所以你应该这样做:
function fb_signup(){
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function success(userCredential){
var userData = userCredential.user;
var uid = userData.uid;
....
关于javascript - 为什么在 createUserWithEmailAndPassword 之后获取 uid 时 Firebase 返回未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53501698/
Firebase v3 Reference Guide表示 createUserWithEmailAndPassword(email, password)返回 firebase.Promise包含非空
我正在编写允许系统管理员创建新帐户的管理函数。由于在使用 createUserWithEmailAndPassword() 函数将用户注册到 firebase 后,系统管理员已经通过系统身份验证,因此
您好,我正在尝试为我的应用构建一个登录系统。我试图确保在进入下一个 Activity 之前我已登录,但如果我进入 while 循环,firebase 似乎会停止尝试登录。像认真的 wtf 吗?顺便说一
我正在学习使用 Firebase,并开始创建我可以在 Firebase 控制台中看到的用户和密码。但是,方法 createUserWithEmailAndPassword 不起作用,我不知道为什么,可
我正在按照基本教程使用 Firebase 创建电子邮件/密码身份验证。 mAuth.createUserWithEmailAndPassword(email, password)
我有以下连接到 firebase 的设置,但出于某种原因,在浏览器控制台中它显示 auth.createUserWithEmailAndPassword() 不是函数。我的代码有问题吗?这是 logi
我想将显示名称添加到刚刚创建的用户。但是当我 createUserWithEmailAndPassword 它说我的 currentUser 为空。哪里不对了? var name = document
在我的系统中,我需要从经过身份验证的用户创建用户,但为此我需要通过 createUserWithEmailAndPassword 创建用户。方法,当我通过此方法创建用户时,身份验证状态更改为当前创建的
Firebase 有一个函数“createUserWithEmailAndPassword”,可以从前端调用它来创建用户。 是什么阻止了某人多次从您的 JavaScript 代码中手动调用该函数?它不
我希望使用 createUserWithEmailAndPassword() 在 Firebase Auth 中创建用户帐户 - 无需登录用户。我希望用户首先验证电子邮件地址。直接登录用户会导致许多不
使用 createUserWithEmailAndPassword 时有两个问题, 它可以在模拟器上运行,但不能在物理设备上以 Debug模式运行 为了让它在物理设备上运行,我可以为电子邮件部分硬编码
我正在创建一个 Android 应用程序并正在实现登录/注册功能。 我正处于注册 Activity 在我的 Firebase 应用程序中成功创建用户条目的阶段,但是,我似乎无法跟踪任务是否成功。 pr
注册表的思路是 将用户邮箱和密码添加到firebase auth,这样就成功了,然后 使用 uid 作为文档 ID 添加新文档,并插入街道字段和值;到 profile 集合,失败且没有错误。 在fir
我是 firebase 的新手,我创建了一个非常简单的应用程序来注册用户。注册后,该用户未显示在我的 firebase 控制台上的用户列表中。我遵循了 Youtube 上的文档和一些教程。我觉得我做了
我正在尝试使用 createUserWithEmailAndPassword 方法来创建用户,但无法这样做。正在调用 OnAuthenticate 方法,但用户对象为空,并且没有在 firebase
我正在处理另一个不需要后端的客户项目。我想使用 Firebase,因为它可以满足我们的所有需求,而且事实上我们已经构建了大部分微型网站。 我们不想要求我们的用户输入电子邮件,因为我们认为它会泄露太多可
我正在关注关于用户管理的 firebase 文档 var firebase = require('firebase'); // Initialize Firebase firebase.initial
我正在使用调用 firbase.auth().createUserWithEmailAndPassword(email, password); 的 React native 注册表单我在 trycat
在使用 Angular5 作为数据库时,我正在尝试从 createUserWithEmailAndPassword(email, password) 创建一个新用户. 但是,当我输入一个已经存在的电子
尝试使用 firebase 注册新帐户时,帐户已成功创建,但 OnCompleteListener 从未触发,甚至 OnFailureListener 也未触发。 我正在尝试这样做,以便当尝试登录一个
我是一名优秀的程序员,十分优秀!