2015-04-16 107 views
0
忘記密碼與ParseUser

我使用Parse.com應用工作作爲後端support.I已經使用ParseUser登錄註冊,但現在我要實現更改密碼忘記密碼,但不知道如何實現它..請幫我實現這個功能。更改密碼,並在Parse.com

我已經用於登錄的ParseUser是如下所述的代碼:

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(); 
     } 
    }); 

回答

8

要要求一個新的密碼(如果用戶忘記了),你可以使用這個:

ParseUser.requestPasswordResetInBackground("[email protected]", 
              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. 
    } 
    } 
}); 

並更改密碼你可以得到當前用戶,並執行以下操作:

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

在文檔中,則有這樣的示例代碼:

ParseUser.requestPasswordResetInBackground("[email protected]", 
              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. 
    } 
    } 
}); 

來源:https://parse.com/docs/android_guide#users-resetting

+0

是''「[email protected]」''你發送請求到電子郵件? – santafebound