How to change password using old password on parse android

橙三吉。 提交于 2019-12-04 07:20:13

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

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