17
17
package io .supertokens .pluginInterface .bulkimport ;
18
18
19
19
import com .google .gson .Gson ;
20
+ import com .google .gson .JsonArray ;
20
21
import com .google .gson .JsonObject ;
21
22
import io .supertokens .pluginInterface .bulkimport .BulkImportStorage .BULK_IMPORT_USER_STATUS ;
22
23
@@ -86,6 +87,38 @@ public JsonObject toJsonObject() {
86
87
return gson .fromJson (gson .toJson (this ), JsonObject .class );
87
88
}
88
89
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
+
89
122
public static class UserRole {
90
123
public String role ;
91
124
public List <String > tenantIds ;
@@ -132,7 +165,7 @@ public String getSuperTokenOrExternalUserId() {
132
165
133
166
public LoginMethod (List <String > tenantIds , String recipeId , boolean isVerified , boolean isPrimary ,
134
167
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 ) {
136
169
this .tenantIds = tenantIds ;
137
170
this .recipeId = recipeId ;
138
171
this .isVerified = isVerified ;
@@ -145,6 +178,7 @@ public LoginMethod(List<String> tenantIds, String recipeId, boolean isVerified,
145
178
this .thirdPartyId = thirdPartyId ;
146
179
this .thirdPartyUserId = thirdPartyUserId ;
147
180
this .phoneNumber = phoneNumber ;
181
+ this .superTokensUserId = superTokensUserId ;
148
182
}
149
183
}
150
184
}
0 commit comments