use of com.amplifyframework.auth.cognito.options.AWSCognitoAuthSignOutOptions in project amplify-android by aws-amplify.
the class AWSCognitoAuthPlugin method signOutLocally.
private void signOutLocally(@NonNull AuthSignOutOptions options, @NonNull Action onSuccess, @NonNull Consumer<AuthException> onError) {
SignOutOptions.Builder signOutOptionsBuilder = SignOutOptions.builder().signOutGlobally(false).invalidateTokens(true);
if (options instanceof AWSCognitoAuthSignOutOptions) {
signOutOptionsBuilder.browserPackage(((AWSCognitoAuthSignOutOptions) options).getBrowserPackage());
}
awsMobileClient.signOut(signOutOptionsBuilder.build(), new Callback<Void>() {
@Override
public void onResult(Void result) {
onSuccess.call();
}
@Override
public void onError(Exception error) {
if (error != null && error.getMessage() != null && error.getMessage().contains("signed-out")) {
onError.accept(new AuthException("Failed to sign out since Auth is already signed out", "No need to sign out - you already are!"));
} else if (error instanceof AuthNavigationException) {
// User cancelled the sign-out screen.
onError.accept(new AuthException.UserCancelledException("The user cancelled the sign-out attempt.", error, "To recover, catch this error, and retry sign-out."));
} else {
onError.accept(new AuthException("Failed to sign out", error, "See attached exception for more details"));
}
}
});
}
Aggregations