AngularFireAuth。使用附加字段创建用户

AngularFireAuth. Create user with additional field

是否可以在 Firebase 中使用附加字段创建用户? 在我的代码中,我可以使用 "email" 和 "password".

创建它们
  this.af.auth.createUser({
    name: formData.value.name,  // gives error*
    email: formData.value.email,
    password: formData.value.password
  }).then(

*错误:

signup.component.ts (26,9): '{ name: any; 类型的参数电子邮件:任何;密码:任意; }' 不可分配给 'EmailPasswordCredentials' 类型的参数。 对象字面量只能指定已知属性,并且 'name' 不存在于类型 'EmailPasswordCredentials'.

我想添加其他字段,例如 "date of birth"、"displayName" 等。

非常感谢

根据 documentation 你不能这样做。但是,您可以将这些附加字段添加到数据中。我使用用户设置结构,其中有相同的用户 ID,然后你就有了一个完整的可用结构。

我使用基本数据结构的文件夹 UserSettings 来保存自定义字段,然后在 Angular 数据提供程序中处理身份验证的同时获取此数据。

"UserSettings": {
    // User Specified Settings should be read/write by the user
    "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid"
    }
}

Firebase 数据

+ - /UserSettings
    + /<user id string>
        + Name
        + BirthDate