Angular 如何在firebase中添加除电子邮件和密码之外的用户额外配置文件信息?
我正在使用firebase和angular4以及angularfire2库。使用电子邮件和密码注册用户后,我可以看到该用户已在firebase的数据库中注册。但是,我不能添加诸如名称、地址等额外字段。我想创建一个'/users'列表,然后使用用户的Uid来存储用户配置文件信息。但文件上说我可以指定姓名和个人资料图片。如果是这种情况,我无法通过身份验证向用户数据库添加任何字段。正如您所提到的,通过firebase文档,您可以使用angularfire2这样做:Angular 如何在firebase中添加除电子邮件和密码之外的用户额外配置文件信息?,angular,firebase,firebase-authentication,angularfire2,Angular,Firebase,Firebase Authentication,Angularfire2,我正在使用firebase和angular4以及angularfire2库。使用电子邮件和密码注册用户后,我可以看到该用户已在firebase的数据库中注册。但是,我不能添加诸如名称、地址等额外字段。我想创建一个'/users'列表,然后使用用户的Uid来存储用户配置文件信息。但文件上说我可以指定姓名和个人资料图片。如果是这种情况,我无法通过身份验证向用户数据库添加任何字段。正如您所提到的,通过firebase文档,您可以使用angularfire2这样做: this.af.auth.cre
this.af.auth.createUser({
email: <UserEmail>,
password: <UserPass>
}).then(
(success) => {
success.auth.updateProfile({
displayName: <UserName>,
photoURL: <UserPhotoURLString>
})
.then(res => console.log("profile updated"))
.catch(err => console.log(err));
}).catch(
(err) => {
console.log(err);
})
正如您在上面的代码附件中所看到的,在使用af.auth.createUser的内置方法后,您将收到一个用户对象,然后您可以使用另一个内置方法success.auth.updateProfile来更新firebase Authentication部分中的用户配置文件区域。
这段代码对我来说非常有效,所以只需根据您的代码进行调整,它:享受。AngularFire2有一个新版本的更新。您可以在新的angularfire版本中试用此代码
this.afAuth.auth.currentUser.updateProfile({
displayName: 'your profile name',
photoURL: 'your pic url'
}).then(() => {
console.log('DisplayName updated')
}).catch(err => console.log(err))
您可以在登录时使用此代码更新用户日期。请提供一个代码示例,显示您尝试的内容和看到的任何错误。您是否阅读了有关用户配置文件的文档@Travis Christian感谢您的回复。是的,我遵循了firebase文档:。我可以在授权部分看到已注册的用户。我想知道的是firebase文档显示我可以添加用户名并上传图片。但在身份验证部分似乎没有名称和编号字段