[英]Firebase Authentication : how to get current user's Password?
i'm new to firebase Authentication .. so, i'm creating a basic app with a profile, i've made an activity to edit basic informations of the user such as DisplayName
and Email
... , i wan't to add the capability of changing passwords, but first , i wan't to check current user's password and compare it to a String
from an InputEditText
that the user must know his current password before changing it. 我是Firebase身份验证的新手..所以,我正在使用配置文件创建一个基本应用程序,我进行了一项活动来编辑用户的基本信息,例如
DisplayName
和Email
...,我不想添加具有更改密码的功能,但是首先,我不会检查当前用户的密码并将其与InputEditText
中的String
进行比较,该String
用户必须先知道其当前密码才能更改它。
EDIT : the thing i'm asking about is i ask the user to write his current Password
in order to be able to change it to a new one to reduce hacking or something like that, like on Facebook
when you're trying to change the Email
or Password
or even the Name
it asks you for your current Password
. 编辑:我要问的是我要求用户写他当前的
Password
,以便能够将其更改为新Password
,以减少黑客入侵或类似的事情,例如在Facebook
尝试更改Password
时Email
, Password
或什至要求您输入当前Password
的Name
。
From the Firebase documentation : 从Firebase文档中 :
Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password —require that the user has recently signed in.
某些安全性敏感的操作(例如删除帐户,设置主电子邮件地址和更改密码)要求用户最近登录。
If you perform one of these actions, and the user signed in too long ago, the action fails and throws
FirebaseAuthRecentLoginRequiredException
.如果您执行这些操作之一,并且用户登录时间太久,则该操作将失败并抛出
FirebaseAuthRecentLoginRequiredException
。 When this happens, re-authenticate the user by getting new sign-in credentials from the user and passing the credentials to reauthenticate.发生这种情况时,请通过从用户获取新的登录凭据并传递凭据以进行重新认证来对用户进行重新认证。 For example:
例如:
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); // Get auth credentials from the user for re-authentication. The example below shows // email and password credentials but there are multiple possible providers, // such as GoogleAuthProvider or FacebookAuthProvider. AuthCredential credential = EmailAuthProvider .getCredential("user@example.com", "password1234"); // Prompt the user to re-provide their sign-in credentials user.reauthenticate(credential) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { Log.d(TAG, "User re-authenticated."); } });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.