【发布时间】:2015-11-06 13:10:33
【问题描述】:
是否可以在 Firebase 中使用字符串而不是电子邮件地址作为用户名?
我试过了,但是createUser 方法要求它是一个电子邮件地址。无论如何我可以绕过这个限制吗?
【问题讨论】:
标签: firebase authentication firebase-authentication
是否可以在 Firebase 中使用字符串而不是电子邮件地址作为用户名?
我试过了,但是createUser 方法要求它是一个电子邮件地址。无论如何我可以绕过这个限制吗?
【问题讨论】:
标签: firebase authentication firebase-authentication
鉴于 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 的例子。
【讨论】: