Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Fail call when trying to recover auth with backgrounded app (#960)
Browse files Browse the repository at this point in the history
We noticed some Android (native) crashes in our application when we're trying to call the get token method when our app is in the background. This is easy to prevent by returning a failed result.
  • Loading branch information
alanrussian authored and mehmetf committed Dec 5, 2018
1 parent 8603d2d commit d89cae7
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,19 @@ public void run(Future<String> tokenFuture) {
} catch (ExecutionException e) {
if (e.getCause() instanceof UserRecoverableAuthException) {
if (shouldRecoverAuth && pendingOperation == null) {
checkAndSetPendingOperation(METHOD_GET_TOKENS, result, email);
Intent recoveryIntent =
((UserRecoverableAuthException) e.getCause()).getIntent();
registrar
.activity()
.startActivityForResult(recoveryIntent, REQUEST_CODE_RECOVER_AUTH);
Activity activity = registrar.activity();
if (activity == null) {
result.error(
ERROR_USER_RECOVERABLE_AUTH,
"Cannot recover auth because app is not in foreground. "
+ e.getLocalizedMessage(),
null);
} else {
checkAndSetPendingOperation(METHOD_GET_TOKENS, result, email);
Intent recoveryIntent =
((UserRecoverableAuthException) e.getCause()).getIntent();
activity.startActivityForResult(recoveryIntent, REQUEST_CODE_RECOVER_AUTH);
}
} else {
result.error(ERROR_USER_RECOVERABLE_AUTH, e.getLocalizedMessage(), null);
}
Expand Down

0 comments on commit d89cae7

Please sign in to comment.