【问题标题】:Multiple account's linked to one (Admin) Firebase多个帐户关联到一个(管理员)Firebase
【发布时间】:2021-02-28 13:02:54
【问题描述】:

我正在尝试为注册用户创建“子”帐户。

因此,在注册并验证帐户后,我希望该用户可以注册更多帐户;供其他人使用,无需额外的电子邮件或身份验证。这些子帐户将链接回主用户,并且该主用户可以删除/更新它们。

我不确定 Firebase 是否可以做到这一点。我做了一些研究,但没有找到简单或任何解决方案。

提前谢谢你。

【问题讨论】:

    标签: ios swift firebase firebase-authentication


    【解决方案1】:

    答案是肯定的,你可以这样做,但有一些注意事项。

    最大的一个是管理员/用户的情况是,当从管理员帐户(在设备上)调用 .createUser 时,它会自动登录 createdUser 并注销管理员。有很多关于这种行为的帖子。

    有许多选项,但我建议使用 Firebase Admin Auth API,它允许您管理用户,而无需持续使用 Firebase 控制台或执行客户端所需的解决方法之一。创建用户的 node.js 示例如下所示

    admin
      .auth()
      .createUser({
        email: 'user@example.com',
        emailVerified: false,
        phoneNumber: '+11234567890',
        password: 'secretPassword',
        displayName: 'John Doe',
        photoURL: 'http://www.example.com/12345678/photo.png',
        disabled: false,
      })
      .then((userRecord) => {
        // See the UserRecord reference doc for the contents of userRecord.
        console.log('Successfully created new user:', userRecord.uid);
      })
      .catch((error) => {
        console.log('Error creating new user:', error);
      });
    

    【讨论】:

    • 很棒的杰,谢谢你的回答,我会调查的!如果您知道任何其他有用的帖子,我将不胜感激!
    猜你喜欢
    • 2018-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多