Search code examples
androidparse-platform

Change Password and Forgot Password with ParseUser in Parse.com


I am working on an application using Parse.com as backend support.I have used ParseUser for login and signup ,but now I have to implement change Password and forgot password ,but don't know how to implement it..Please help me to implement this functionalities.

The code which I have used to login the ParseUser is as follows:

ParseUser.logInInBackground(str_email2, str_password2, new LogInCallback() {
        @Override
        public void done(ParseUser user, ParseException e) {
            dlg.dismiss();
            if(e == null)
            {
                Log.d(">>>","ObjId>>"+user.getObjectId()+"  Username>>>"+user.getUsername());

            }
            else
                loginUnSuccessful();
        }
    });

Solution

  • To request a new password (in case the user forgot it) you can use this:

    ParseUser.requestPasswordResetInBackground("myemail@example.com",
                                               new RequestPasswordResetCallback() {
      public void done(ParseException e) {
        if (e == null) {
          // An email was successfully sent with reset instructions.
        } else {
          // Something went wrong. Look at the ParseException to see what's up.
        }
      }
    });
    

    And to change a password you can just get the current user and do the following:

    ParseUser currentUser = ParseUser.getCurrentUser();
    currentUser.setPassword("new_password");
    currentUser.saveInBackground();