【问题标题】:Firebase Authentication without email as username?没有电子邮件作为用户名的 Firebase 身份验证?
【发布时间】:2015-11-06 13:10:33
【问题描述】:

是否可以在 Firebase 中使用字符串而不是电子邮件地址作为用户名?

我试过了,但是createUser 方法要求它是一个电子邮件地址。无论如何我可以绕过这个限制吗?

【问题讨论】:

    标签: firebase authentication firebase-authentication


    【解决方案1】:

    鉴于 Firebase 电子邮件+密码身份验证无法验证电子邮件地址是否确实存在,您可以在字符串末尾填充任何域。只要结果是语法上有效的电子邮件地址,它就可以工作:

    var name = 'puf'; // TODO: read this from the form where the user enters their username
    var password = 'geheim';
    var email = name + '@whateverdomain.com';
    ref.createUser({ email: email, password: password}...
    

    请注意,使用这种方法,用户将无法接收密码恢复电子邮件。

    更新functions-samples repo 中有一个how to implement username+password sign-in 的例子。

    【讨论】:

    • 这篇文章可能不是最新的:I found this。 “自定义”登录。在你写这篇文章的时候,这个习惯是不起作用还是不存在?
    • 按照现代标准,这个答案确实是古老的。但我只是添加了一个链接,指向如何实现这一点的最新示例。
    猜你喜欢
    • 2021-10-05
    • 2017-08-10
    • 2023-03-18
    • 2018-02-10
    • 2019-05-01
    • 2021-12-08
    • 2022-08-07
    • 1970-01-01
    • 2021-03-26
    相关资源
    最近更新 更多