FirebaseAuth-让用户使用任何提供程序更改密码-Android [英] FirebaseAuth - Let user change password using any provider - Android

查看:82
本文介绍了FirebaseAuth-让用户使用任何提供程序更改密码-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个社交媒体应用程序,我正在使用 FirebaseUI 让用户使用电子邮件,Google或Facebook登录/注册该应用程序.

  1. 如果使用电子邮件"作为密码,如何让用户以后更改密码?提供者?

  2. 如果使用Facebook或Google作为提供者,我可以允许他/她选择更改密码,让他/她将电子邮件密码"设置为身份验证方法吗?.

  3. 用户执行的更改密码操作应使用用户输入的新密码在Firebase中将电子邮件密码"设置为身份验证方法".

  4. 然后,用户应该能够使用电子邮件密码或与同一电子邮件链接的身份验证提供程序(Facebook/Google)登录.

解决方案

回答您的问题:

  1. .

以下是用于更改/更新用户密码的示例代码段:

  FirebaseUser用户= FirebaseAuth.getInstance().getCurrentUser();字符串newPassword ="SOME-SECURE-PASSWORD";user.updatePassword(newPassword).addOnCompleteListener(new OnCompleteListener< Void>(){@Overridepublic void onComplete(@NonNull Task< Void>任务){如果(task.isSuccessful()){Log.d(TAG,用户密码已更新.");}}}); 

此处中可以找到使用Firebase User的详细信息..>

2.一种.在您的应用程序中更改 密码:

Facebook,Google和Twitter之类的登录提供程序不会打开此功能(API),以防止中间人和其他攻击/滥用.

b.用户登录后在服务提供商中更改了密码

用户仍然可以登录到您的应用,身份验证过程直接与服务提供商联系,因此您不必担心!

c.使用相同的电子邮件地址进行多次身份验证.

引用

假设用户A使用Facebook登录到我的应用程序,然后他进入了我的APP中的个人资料,并更改了密码,下次登录时,我希望他有2个选择:1-通常使用Facebook登录2-使用他的facebook电子邮件和他之前保存的密码登录

答案是,但是您必须先合并详细信息,这是参考.实际上,您可以通过标识相同的Firebase用户ID来链接/合并同一电子邮件地址的用户详细信息,而无需考虑他们用来登录的身份验证提供程序.

例如,使用密码登录的用户可以链接Google帐户,以后再使用这两种方法登录.或者,匿名用户可以链接Facebook帐户,然后再登录Facebook以继续使用您的应用.

希望有帮助!

I have a social media app, I'm using FirebaseUI to let users sign in/up to the app,using Email, Google or Facebook.

  1. How can I let user to change his/her password later if using "Email" as a provider?

  2. If using Facebook or Google as providers can I let him/her set Email-Password as Authentication Method by giving him/her an option to change password?.

  3. The change password action from user should set Email-Password as Authentication Method in firebase with a new password input from the user.

  4. Then, The user should be able to login using Email-Password or the Authentication Provider( Facebook/Google) linked with same email.

解决方案

Answering your question:

  1. Yes.

Here is a sample code snippet for changing/updating the user password:

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String newPassword = "SOME-SECURE-PASSWORD";

user.updatePassword(newPassword)
    .addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                Log.d(TAG, "User password updated.");
            }
        }
    });

Details of using Firebase User is available here.

2. a. Changing the password in your app:

NO

The SignIn Providers such as Facebook, Google and Twitter do not open this features (API) to prevent middleman and other attacks/abuses.

b. User changed the password in the service provider after signed-in

The user is still able to login to your app, authentication process is deal directly to the service provider, so you don't have to worry!

c. Multiple authentication with the same email address.

Referring to

let's say user A logged in using Facebook to my app, then he went to his profile in MY APP , and changed his password, next time to login I want him to have 2 options: 1- Login using Facebook normally 2- Login using his facebook Email + the password that he saved earlier

The answer is YES, but you have to merge the details first, here is the reference. You can actually link/merge the user details of the same email address by identifying the same Firebase user ID regardless of the authentication provider they used to sign in.

For example, a user who signed in with a password can link a Google account and sign in with either method in the future. Or, an anonymous user can link a Facebook account and then, later, sign in with Facebook to continue using your app.

Hope it helps!

这篇关于FirebaseAuth-让用户使用任何提供程序更改密码-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆