Skip to content

Commit

Permalink
fix: session for mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Mar 14, 2024
1 parent 1443ae5 commit 6036e59
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/main/java/io/supertokens/session/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,30 @@ public static SessionInformationHolder createNewSession(TenantIdentifier tenantI
sessionHandle += "_" + tenantIdentifier.getTenantId();
}

io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping = UserIdMapping.getUserIdMapping(
tenantIdentifier.toAppIdentifier(), storage, recipeUserId, UserIdType.EXTERNAL);
if (userIdMapping != null) {
recipeUserId = userIdMapping.superTokensUserId;
}

String primaryUserId = recipeUserId;
if (storage.getType().equals(STORAGE_TYPE.SQL)) {

if (storage.getType() == STORAGE_TYPE.SQL) {
io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping = UserIdMapping.getUserIdMapping(
tenantIdentifier.toAppIdentifier(), storage, recipeUserId, UserIdType.EXTERNAL);
if (userIdMapping != null) {
recipeUserId = userIdMapping.superTokensUserId;
}

primaryUserId = StorageUtils.getAuthRecipeStorage(storage)
.getPrimaryUserIdStrForUserId(tenantIdentifier.toAppIdentifier(), recipeUserId);
if (primaryUserId == null) {
primaryUserId = recipeUserId;
}
}

HashMap<String, String> userIdMappings = UserIdMapping.getUserIdMappingForSuperTokensUserIds(
tenantIdentifier.toAppIdentifier(), storage,
new ArrayList<>(Arrays.asList(primaryUserId, recipeUserId)));
if (userIdMappings.containsKey(primaryUserId)) {
primaryUserId = userIdMappings.get(primaryUserId);
}
if (userIdMappings.containsKey(recipeUserId)) {
recipeUserId = userIdMappings.get(recipeUserId);
HashMap<String, String> userIdMappings = UserIdMapping.getUserIdMappingForSuperTokensUserIds(
tenantIdentifier.toAppIdentifier(), storage,
new ArrayList<>(Arrays.asList(primaryUserId, recipeUserId)));
if (userIdMappings.containsKey(primaryUserId)) {
primaryUserId = userIdMappings.get(primaryUserId);
}
if (userIdMappings.containsKey(recipeUserId)) {
recipeUserId = userIdMappings.get(recipeUserId);
}
}

String antiCsrfToken = enableAntiCsrf ? UUID.randomUUID().toString() : null;
Expand Down

0 comments on commit 6036e59

Please sign in to comment.