Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Oct 25, 2023
1 parent 2b54207 commit d632005
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.supertokens.pluginInterface.multitenancy.*;
import io.supertokens.storage.postgresql.Start;
import io.supertokens.storage.postgresql.queries.utils.JsonUtils;
import io.supertokens.storage.postgresql.utils.Utils;

import java.sql.Connection;
import java.sql.ResultSet;
Expand All @@ -48,25 +49,11 @@ public static TenantConfigSQLHelper.TenantConfigRowMapper getInstance(ThirdParty
return new TenantConfigSQLHelper.TenantConfigRowMapper(providers);
}

private static String[] getStringArrayFromJsonString(String input) {
if (input == null) {
return new String[0];
}
return new Gson().fromJson(input, String[].class);
}

private static JsonArray getJsonArrayFromJsonString(String input) {
if (input == null) {
return new JsonArray();
}
return new Gson().fromJson(input, JsonArray.class);
}

@Override
public TenantConfig map(ResultSet result) throws StorageQueryException {
try {
String[] firstFactors = getStringArrayFromJsonString(result.getString("first_factors"));
String[] defaultRequiredFactorIds = getStringArrayFromJsonString(result.getString("default_required_factors"));
String[] firstFactors = Utils.getStringArrayFromJsonString(result.getString("first_factors"));
String[] defaultRequiredFactorIds = Utils.getStringArrayFromJsonString(result.getString("default_required_factors"));

return new TenantConfig(
new TenantIdentifier(result.getString("connection_uri_domain"), result.getString("app_id"), result.getString("tenant_id")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package io.supertokens.storage.postgresql.utils;

import com.google.gson.Gson;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

Expand Down Expand Up @@ -53,4 +55,11 @@ public static String generateCommaSeperatedQuestionMarks(int size) {
}
return builder.toString();
}

public static String[] getStringArrayFromJsonString(String input) {
if (input == null) {
return null;
}
return new Gson().fromJson(input, String[].class);
}
}

0 comments on commit d632005

Please sign in to comment.