How to change password using old password on parse android

*爱你&永不变心* 提交于 2019-12-06 03:48:55

问题


I have an android app in which user can change his/her password my problem is how i can verify old password of user using parse i have 3 edit text "old password, new password and confirm new password".

I search on parse.com but can't find any solution parse do not fetch data using get password. i am doing this

String get_confrimpass=currentuser.getpassword();



if(get_confrimpass.replaceAll("\\s", "").equals(current_pass_check))
            {           }

回答1:


You can try logging them in using there current username and the password that they have given to you. If the loggin is successful the old password is correct. I.e

ParseUser.logInInBackground(ParseUser.getCurrentUser().getUsername(), currentPassword, new LogInCallback() {  
    public void done(ParseUser user, ParseException e) {    
        if (user != null) {      
             // Hooray! The password is correct 
        } else {      
             // The password was incorrect 
        }  
   }
});

In the example above the 'currentPassword' variable is the text that you would retreive from the 'Old Password' EditText




回答2:


final ParseUser currentUser = ParseUser.getCurrentUser();
final String userName = ParseUser.getCurrentUser().getUsername();

ParseUser.logInInBackground(userName, oldPass, new LogInCallback() {
   @Override
   public void done(ParseUser user, ParseException e) {
         if (user != null) {
            if (et.length() < 6)
              Toast(getActivity(), "Password is short, Min char 6", Toast.LENGTH_LONG).show();
            else {
                currentUser.setPassword(newPass);
                currentUser.saveInBackground();
                ParseUser.logOut();
                ParseUser.logInInBackground(userName, newPass, new LogInCallback() {
                @Override
                public void done(ParseUser parseUser, ParseException e) {
                    if (e == null) {
                    Toast(getActivity(), "Password change", Toast.LENGTH_LONG).show();
                     } else
             Toast(getActivity(), "Network Error", Toast.LENGTH_LONG).show();
                                        }
                                    });
                                }
                            } else {
                                new CustomToast(getActivity(), "Old Password is incorrect", Toast.LENGTH_LONG);
                            }
                        }
                    });


来源:https://stackoverflow.com/questions/27482566/how-to-change-password-using-old-password-on-parse-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!