Search in sources :

Example 6 with LogoutUseCase

use of org.eyeseetea.malariacare.domain.usecase.LogoutUseCase 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();
            }
        });
    }
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase) CredentialsLocalDataSource(org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource) Credentials(org.eyeseetea.malariacare.domain.entity.Credentials) ICredentialsRepository(org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)

Example 7 with LogoutUseCase

use of org.eyeseetea.malariacare.domain.usecase.LogoutUseCase in project pictureapp by EyeSeeTea.

the class BaseActivityStrategy method onCreate.

@Override
public void onCreate() {
    mAuthenticationManager = new AuthenticationManager(mBaseActivity);
    mLogoutUseCase = new LogoutUseCase(mAuthenticationManager);
}
Also used : IAuthenticationManager(org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager) AuthenticationManager(org.eyeseetea.malariacare.data.authentication.AuthenticationManager) LogoutUseCase(org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)

Aggregations

AuthenticationManager (org.eyeseetea.malariacare.data.authentication.AuthenticationManager)7 LogoutUseCase (org.eyeseetea.malariacare.domain.usecase.LogoutUseCase)7 IAuthenticationManager (org.eyeseetea.malariacare.domain.boundary.IAuthenticationManager)5 Intent (android.content.Intent)2 LoginActivity (org.eyeseetea.malariacare.LoginActivity)2 IntentFilter (android.content.IntentFilter)1 CredentialsLocalDataSource (org.eyeseetea.malariacare.data.database.CredentialsLocalDataSource)1 PullController (org.eyeseetea.malariacare.data.sync.importer.PullController)1 IPullController (org.eyeseetea.malariacare.domain.boundary.IPullController)1 IAsyncExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IAsyncExecutor)1 IMainExecutor (org.eyeseetea.malariacare.domain.boundary.executors.IMainExecutor)1 ICredentialsRepository (org.eyeseetea.malariacare.domain.boundary.repositories.ICredentialsRepository)1 Credentials (org.eyeseetea.malariacare.domain.entity.Credentials)1 PullUseCase (org.eyeseetea.malariacare.domain.usecase.pull.PullUseCase)1 AsyncExecutor (org.eyeseetea.malariacare.presentation.executors.AsyncExecutor)1 UIThreadExecutor (org.eyeseetea.malariacare.presentation.executors.UIThreadExecutor)1