2016-10-18 2 views
1

Я загрузил SDK Applizic Chat для Android. В настоящее время я обнаружил, что вы можете войти в учетную запись пользователя с именем пользователя и любым паролем. Мне интересно, как мне реализовать код, чтобы проверить, правильно ли введен пароль?Appozic Android Chat App - Как проверить пароль для пользователя

ответ

1

Выполняя ввод/регистрацию Applozic, вы должны установить user.setAuthenticationTypeId (User.AuthenticationType.APPLOZIC.getValue()); и установить пароль .Если пароль неверен, вы получите исключение в OnFailure из UserLoginTask там вы можете проверить эту строку в исключения Invalid uername/пароль

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

Смежные вопросы