Applozic Android 聊天应用程序 - 如何检查用户密码

Applozic Android Chat App - How to check password for a user

我下载了 android 的 Applozic Chat SDK。目前我发现您可以使用用户名和任何密码登录用户帐户。我想知道我应该如何实现代码来检查用户是否正确输入了密码?

在执行 Applozic Login/Register 时,您需要设置 user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue()); 并设置密码。如果密码不正确,您将在 UserLoginTask 的 onFailure 中得到异常,您可以在异常 Invalid uername/password

中检查此字符串
UserLoginTask.TaskListener listener = new UserLoginTask.TaskListener() {                  

 @Override          
  public void onSuccess(RegistrationResponse registrationResponse, Context context) {           
 //After successful registration with Applozic server the callback    will come here 
 }                       

@Override             
public void onFailure(RegistrationResponse registrationResponse, Exception exception) {  
//If any failure in registration the callback  will come here 
//Here Invalid uername/password exception will be thrown if password is wrong check for the string Invalid uername/password in exception

}};                      

User user = new User();          
user.setUserId(userId); //userId it can be any unique user identifier
user.setDisplayName(displayName); //displayName is the name of the user which will be shown in chat messages
user.setEmail(email); //optional   
user.setImageLink("");//optional,pass your image link
user.setPassword(password);//Set the password
user.setAuthenticationTypeId(User.AuthenticationType.APPLOZIC.getValue());//You  need to set the Authentication type 
new UserLoginTask(user, listener, this).execute((Void) null);

Applozic login sample github code link