Skip to content

Commit f731ecb

Browse files
authored
Merge pull request #105 from intercom/vr/fix-login-with-attributes-with-no-user-id
fix: Do not query for userId when it is not present
2 parents 4b1b79f + e1315f5 commit f731ecb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

android/src/main/java/com/intercom/reactnative/IntercomModule.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ public void loginUserWithUserAttributes(ReadableMap params, Promise promise) {
136136
Boolean hasEmail = params.hasKey("email") && IntercomHelpers.getValueAsStringForKey(params, "email").length() > 0;
137137
Boolean hasUserId = params.hasKey("userId") && IntercomHelpers.getValueAsStringForKey(params, "userId").length() > 0;
138138
Registration registration = null;
139-
String userId = IntercomHelpers.getValueAsStringForKey(params, "userId");
140-
if (hasEmail) {
139+
if (hasEmail && hasUserId) {
141140
String email = IntercomHelpers.getValueAsStringForKey(params, "email");
142-
if (hasUserId) {
143-
registration = new Registration().withEmail(email).withUserId(userId);
144-
} else {
145-
registration = Registration.create().withEmail(email);
146-
}
141+
String userId = IntercomHelpers.getValueAsStringForKey(params, "userId");
142+
registration = new Registration().withEmail(email).withUserId(userId);
143+
} else if (hasEmail) {
144+
String email = IntercomHelpers.getValueAsStringForKey(params, "email");
145+
registration = new Registration().withEmail(email);
147146
} else if (hasUserId) {
148-
registration = Registration.create().withUserId(userId);
147+
String userId = IntercomHelpers.getValueAsStringForKey(params, "userId");
148+
registration = new Registration().withUserId(userId);
149149
} else {
150150
Log.e(NAME, "loginUserWithUserAttributes called with invalid userId or email");
151151
Log.e(NAME, "You must provide userId or email");

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ PODS:
7474
- fmt (6.2.1)
7575
- glog (0.3.5)
7676
- Intercom (15.0.0)
77-
- intercom-react-native (5.0.0):
77+
- intercom-react-native (5.1.1):
7878
- Intercom (~> 15.0.0)
7979
- React-Core
8080
- libevent (2.1.12)
@@ -534,7 +534,7 @@ SPEC CHECKSUMS:
534534
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
535535
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
536536
Intercom: c4d9286eb12277dd104e7a49aead819337772716
537-
intercom-react-native: 83a85583016a294827177465301795ec46e5a310
537+
intercom-react-native: a9174e41c57228fa94ee832f771b6977826254a3
538538
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
539539
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
540540
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda

0 commit comments

Comments
 (0)