Skip to content

Commit

Permalink
fix(auth, android): avoid crash on react-native < 0.63
Browse files Browse the repository at this point in the history
At minimum phone OTP auth and perhaps other scenarios may crash on
very old react-native, because old react-native used to throw an exception
if a map didn't contain a key, whereas newer react-native just returns null

Newer code here related to multi-factor auth relied on that returns-null
behavior and did not handle the case where an exception may be thrown if
a key didn't exist

Avoid this exception+crash by explicitly checking for our desired key prior to
getting its value
  • Loading branch information
mikehardy committed Aug 23, 2023
1 parent cc2d642 commit 3fee0d6
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,10 @@ private void promiseWithAuthResult(AuthResult authResult, Promise promise) {
*/
private void promiseRejectAuthException(Promise promise, Exception exception) {
WritableMap error = getJSError(exception);
final String sessionId = error.getString("sessionId");
String sessionId = null;
if (error.hasKey("sessionId")) {
sessionId = error.getString("sessionId");
}
final MultiFactorResolver multiFactorResolver = mCachedResolvers.get(sessionId);
WritableMap resolverAsMap = Arguments.createMap();
if (multiFactorResolver != null) {
Expand Down

1 comment on commit 3fee0d6

@vercel
Copy link

@vercel vercel bot commented on 3fee0d6 Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.