Skip to content

Fix issue 1156 #1158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
Expand Down Expand Up @@ -56,6 +57,8 @@

public class SignedInActivity extends AppCompatActivity {

private static final String TAG = "SignedInActivity";

private static final String EXTRA_IDP_RESPONSE = "extra_idp_response";
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";

Expand Down Expand Up @@ -126,6 +129,7 @@ public void onComplete(@NonNull Task<Void> task) {
startActivity(AuthUiActivity.createIntent(SignedInActivity.this));
finish();
} else {
Log.w(TAG, "signOut:failure", task.getException());
showSnackbar(R.string.sign_out_failed);
}
}
Expand Down
27 changes: 26 additions & 1 deletion auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
* for examples on how to get started with FirebaseUI Auth.
*/
public class AuthUI {

private static final String TAG = "AuthUI";

@StringDef({
EmailAuthProvider.PROVIDER_ID,
PhoneAuthProvider.PROVIDER_ID,
Expand Down Expand Up @@ -268,9 +271,31 @@ public static int getDefaultTheme() {
@NonNull
public Task<Void> signOut(@NonNull Context context) {
mAuth.signOut();

Task<Void> maybeDisableAutoSignIn = GoogleApiUtils.getCredentialsClient(context)
.disableAutoSignIn()
.continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(@NonNull Task<Void> task) throws Exception {
// We want to ignore a specific exception, since it's not a good reason
// to fail (see Issue 1156).
if (!task.isSuccessful() && (task.getException() instanceof ApiException)) {
ApiException ae = (ApiException) task.getException();
if (ae.getStatusCode() == CommonStatusCodes.CANCELED) {
Log.w(TAG, "Could not disable auto-sign in, maybe there are no " +
"SmartLock accounts available?", ae);

return Tasks.forResult(null);
}
}

return task;
}
});

return Tasks.whenAll(
signOutIdps(context),
GoogleApiUtils.getCredentialsClient(context).disableAutoSignIn());
maybeDisableAutoSignIn);
}

/**
Expand Down