简体   繁体   English

Firebase身份验证:如何获取当前用户的密码?

[英]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身份验证的新手..所以,我正在使用配置文件创建一个基本应用程序,我进行了一项活动来编辑用户的基本信息,例如DisplayNameEmail ...,我不想添加具有更改密码的功能,但是首先,我不会检查当前用户的密码并将其与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尝试更改PasswordEmailPassword或什至要求您输入当前PasswordName

![例

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.

相关问题 如何在UserDetailsS​​ervice中获取当前的用户身份验证 - How to get current user authentication inside UserDetailsService 如何获取当前用户的Firebase token - How to get Firebase token of current user (Android) 在允许用户更新密码之前,如何进行询问用户当前密码的对话? - (Android) How to make a dialogue asking the user's current password before allowing the user to update the password? 如何在smack中获取当前用户的名字 - How to get current user's name in smack 如何获取用户的当前城市? - How to get a user's current city? 如何在Firebase Android中获取当前用户的Push ID? - How to get the Push id of current user in Firebase Android? 如何从Firebase获取当前的用户个人资料图像和名称? - How to get the current user profile image and name from Firebase? 如何从当前登录的用户 Firebase 获取数据 - How to get data from current logged in user Firebase 使用 Android 进行 Firebase 电子邮件和密码身份验证 - 用户注册 - Firebase Email and Password Authentication with android - User sign up 使用 user.reauthenticate 更新 Firebase 身份验证密码 - Updating Firebase Authentication password using user.reauthenticate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM