|
83 | 83 | import com.amazonaws.mobile.client.results.UserCodeDeliveryDetails; |
84 | 84 | import com.amazonaws.mobile.config.AWSConfiguration; |
85 | 85 | import com.amazonaws.mobileconnectors.cognitoauth.AuthClient; |
| 86 | +import com.amazonaws.mobileconnectors.cognitoauth.exceptions.AuthNavigationException; |
86 | 87 | import com.amazonaws.mobileconnectors.cognitoidentityprovider.util.CognitoJWTParser; |
87 | 88 | import com.amazonaws.services.cognitoidentity.model.NotAuthorizedException; |
88 | 89 | import org.json.JSONException; |
@@ -934,6 +935,12 @@ public void onError(Exception error) { |
934 | 935 | // global sign out by locally signing them out here. |
935 | 936 | if (error instanceof NotAuthorizedException) { |
936 | 937 | signOutLocally(options, onSuccess, onError); |
| 938 | + } else if (error instanceof AuthNavigationException) { |
| 939 | + // User cancelled the sign-out screen. |
| 940 | + onError.accept(new AuthException.UserCancelledException( |
| 941 | + "The user cancelled the sign-out attempt.", error, |
| 942 | + "To recover, catch this error, and retry sign-out." |
| 943 | + )); |
937 | 944 | } else { |
938 | 945 | // Any other runtime exception means global sign out failed for another reason |
939 | 946 | // (e.g. device offline), in which case we pass that error back to the customer. |
@@ -989,6 +996,12 @@ public void onError(Exception error) { |
989 | 996 | "Failed to sign out since Auth is already signed out", |
990 | 997 | "No need to sign out - you already are!" |
991 | 998 | )); |
| 999 | + } else if (error instanceof AuthNavigationException) { |
| 1000 | + // User cancelled the sign-out screen. |
| 1001 | + onError.accept(new AuthException.UserCancelledException( |
| 1002 | + "The user cancelled the sign-out attempt.", error, |
| 1003 | + "To recover, catch this error, and retry sign-out." |
| 1004 | + )); |
992 | 1005 | } else { |
993 | 1006 | onError.accept(new AuthException( |
994 | 1007 | "Failed to sign out", |
@@ -1061,13 +1074,17 @@ public void onResult(UserStateDetails details) { |
1061 | 1074 |
|
1062 | 1075 | @Override |
1063 | 1076 | public void onError(Exception error) { |
1064 | | - onException.accept( |
1065 | | - new AuthException( |
1066 | | - "Sign in with web UI failed", |
1067 | | - error, |
1068 | | - "See attached exception for more details" |
1069 | | - ) |
1070 | | - ); |
| 1077 | + if (error instanceof AuthNavigationException) { |
| 1078 | + onException.accept(new AuthException.UserCancelledException( |
| 1079 | + "The user cancelled the sign-in attempt, so it did not complete.", |
| 1080 | + error, "To recover: catch this error, and show the sign-in screen again." |
| 1081 | + )); |
| 1082 | + } else { |
| 1083 | + onException.accept(new AuthException( |
| 1084 | + "Sign-in with web UI failed", error, |
| 1085 | + "See attached exception for more details" |
| 1086 | + )); |
| 1087 | + } |
1071 | 1088 | } |
1072 | 1089 | }); |
1073 | 1090 | } |
|
0 commit comments