2015-05-18 46 views
0

我是新來解析,試圖通過重置密碼:解析密碼重置

user.requestPasswordResetInBackground(password.getText().toString(), new RequestPasswordResetCallback() { 
    @Override 
    public void done(com.parse.ParseException e) { 
     if (e == null) { 
      Toast.makeText(getApplicationContext(), "Password rest email has been sent to your inbox", Toast.LENGTH_LONG).show(); 


     }else if(e.getCode()== com.parse.ParseException.INVALID_EMAIL_ADDRESS){ 
      Toast.makeText(getApplicationContext(),"Email not found",Toast.LENGTH_LONG).show(); 
     } 
    } 
}); 

一切都很好,電子郵件將被髮送到收件箱中,通過我怎麼能告訴解析驗證至少密碼8個字符(它取所有東西,甚至1234) 謝謝

回答

1

我想你可以寫一個cloud code,所以在更新_User對象之前,請檢查user.get(「password」).length。 是這樣的:

PF.Cloud.beforeSave("_User", function(request, response) { 
    //Prototype linking 
    var user = request.object; 
    if (user.get("password").length >= 8) { 
     response.success(); 
    } else { 
     response.error("Password too short"); 
    } 
}); 

欲瞭解更多信息,請訪問參考:Cloud Code