Skip to content

Commit f896bb7

Browse files
authored
Merge pull request #175 from supertokens/feat/bulk_migration_return_userids
feat: bulk migration return userids
2 parents f091baf + 7cef584 commit f896bb7

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [7.1.1]
11+
12+
- Adds support for BulkImportUser's id generation while the upload is happening
1013

1114
## [7.1.0]
1215

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java-library'
33
}
44

5-
version = "7.1.0"
5+
version = "7.1.1"
66

77
repositories {
88
mavenCentral()

src/main/java/io/supertokens/pluginInterface/bulkimport/BulkImportUser.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package io.supertokens.pluginInterface.bulkimport;
1818

1919
import com.google.gson.Gson;
20+
import com.google.gson.JsonArray;
2021
import com.google.gson.JsonObject;
2122
import io.supertokens.pluginInterface.bulkimport.BulkImportStorage.BULK_IMPORT_USER_STATUS;
2223

@@ -86,6 +87,38 @@ public JsonObject toJsonObject() {
8687
return gson.fromJson(gson.toJson(this), JsonObject.class);
8788
}
8889

90+
public JsonObject toResponseJson(){
91+
JsonObject response = new JsonObject();
92+
response.addProperty("userId", externalUserId == null ? id : externalUserId);
93+
JsonArray loginArray = new JsonArray();
94+
for(LoginMethod loginMethod: loginMethods){
95+
JsonObject lmObj = new JsonObject();
96+
lmObj.addProperty("recipeId", loginMethod.recipeId);
97+
lmObj.addProperty("userId", loginMethod.getSuperTokenOrExternalUserId());
98+
lmObj.add("tenants", gson.toJsonTree(loginMethod.tenantIds));
99+
switch (loginMethod.recipeId) {
100+
case "emailpassword": {
101+
lmObj.addProperty("email", loginMethod.email);
102+
break;
103+
}
104+
case "thirdparty": {
105+
lmObj.addProperty("email", loginMethod.email);
106+
lmObj.addProperty("thirdpartyId", loginMethod.thirdPartyId);
107+
lmObj.addProperty("thirdpartyUserId", loginMethod.thirdPartyUserId);
108+
break;
109+
}
110+
case "passwordless": {
111+
lmObj.addProperty("email", loginMethod.email);
112+
lmObj.addProperty("phoneNumber", loginMethod.phoneNumber);
113+
break;
114+
}
115+
}
116+
loginArray.add(lmObj);
117+
}
118+
response.add("loginMethods", loginArray);
119+
return response;
120+
}
121+
89122
public static class UserRole {
90123
public String role;
91124
public List<String> tenantIds;
@@ -132,7 +165,7 @@ public String getSuperTokenOrExternalUserId() {
132165

133166
public LoginMethod(List<String> tenantIds, String recipeId, boolean isVerified, boolean isPrimary,
134167
long timeJoinedInMSSinceEpoch, String email, String passwordHash, String hashingAlgorithm, String plainTextPassword,
135-
String thirdPartyId, String thirdPartyUserId, String phoneNumber) {
168+
String thirdPartyId, String thirdPartyUserId, String phoneNumber, String superTokensUserId) {
136169
this.tenantIds = tenantIds;
137170
this.recipeId = recipeId;
138171
this.isVerified = isVerified;
@@ -145,6 +178,7 @@ public LoginMethod(List<String> tenantIds, String recipeId, boolean isVerified,
145178
this.thirdPartyId = thirdPartyId;
146179
this.thirdPartyUserId = thirdPartyUserId;
147180
this.phoneNumber = phoneNumber;
181+
this.superTokensUserId = superTokensUserId;
148182
}
149183
}
150184
}

0 commit comments

Comments
 (0)