use of org.eyeseetea.malariacare.domain.entity.Credentials in project pictureapp by EyeSeeTea.
the class LoginActivityStrategy method checkCredentials.
@Override
public void checkCredentials(Credentials credentials, final Callback callback) {
ICredentialsRepository credentialsLocalDataSource = new CredentialsLocalDataSource();
Credentials savedCredentials = credentialsLocalDataSource.getOrganisationCredentials();
if (savedCredentials == null || savedCredentials.isEmpty() || savedCredentials.getUsername().equals(credentials.getUsername()) && (!savedCredentials.getPassword().equals(credentials.getPassword()) || !savedCredentials.getServerURL().equals(credentials.getServerURL()))) {
callback.onSuccessDoLogin();
} else if (savedCredentials.getUsername().equals(credentials.getUsername()) && savedCredentials.getPassword().equals(credentials.getPassword()) && savedCredentials.getServerURL().equals(credentials.getServerURL())) {
callback.onSuccess();
} else {
IAuthenticationManager iAuthenticationManager = new AuthenticationManager(loginActivity);
LogoutUseCase logoutUseCase = new LogoutUseCase(iAuthenticationManager);
AlarmPushReceiver.cancelPushAlarm(loginActivity);
logoutUseCase.execute(new LogoutUseCase.Callback() {
@Override
public void onLogoutSuccess() {
callback.onSuccessDoLogin();
}
@Override
public void onLogoutError(String message) {
callback.onError();
}
});
}
}
Aggregations