用户名身份验证而不是电子邮件

用户名身份验证而不是电子邮件

问题描述:

借助 Firebase,我可以使用电子邮件地址注册和登录用户.但是,如果我希望应用程序基于用户名怎么办.例如,您会使用Bobzilla"而不是Bob@mail.com"登录?

With Firebase I can sign up and login users using email addresses. However what if I want the app to be username based. For example, you would log in with "Bobzilla" instead of "Bob@mail.com"?

Firebase 可以做到这一点吗?

Is this possible with Firebase?

Firebase 身份验证中没有内置的默认用户名+密码提供程序.但您可以使用 Firebase 文档中的说明创建自己的自定义身份提供程序>.这需要在受信任的环境中运行的代码,您可以使用自己的服务器或 Cloud Functions for Firebase.现在甚至有一个在functions-samples repo中的例子.

There is no default username+password provider built into Firebase Authentication. But you can create your own custom identity provider using the instructions in the Firebase documentation. This requires code that runs in a trusted environment, for which you can use your own server or Cloud Functions for Firebase. There is now even an example of this in the functions-samples repo.

或者:您可以使用内置的电子邮件+密码提供程序,只需在用户名后面添加任何域即可.因此,一旦您确定了用户名,请使用 @vikzillasapp.com 注册您的用户.

Alternatively: you can use the built-in email+password provider and simply add any domain behind the username. So once you have determined the user name, register your user with <username>@vikzillasapp.com.

请注意,如果用户忘记密码,这将使他们无法重置密码,因为 Firebase 使用电子邮件地址发送密码重置电子邮件.

Note that this will make it impossible to for the user to reset their password if they forget it, since Firebase uses the email address to send the password reset email.