Skip to content

Commit

Permalink
reformats code
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Jul 8, 2024
1 parent 36fa29e commit b4cdd5a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ public static List<String> isEmailVerified_transaction(Start start, Connection s

HashMap<String, String> supertokensUserIdToExternalUserIdMap =
UserIdMappingQueries.getUserIdMappingWithUserIds_Transaction(
start,
sqlCon, appIdentifier, supertokensUserIds);
start,
sqlCon, appIdentifier, supertokensUserIds);
HashMap<String, String> externalUserIdToSupertokensUserIdMap = new HashMap<>();

List<String> supertokensOrExternalUserIdsToQuery = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ public static TenantConfig[] getAllTenants(Start start) throws StorageQueryExcep
// Map (tenantIdentifier) -> thirdPartyId -> provider
HashMap<TenantIdentifier, HashMap<String, ThirdPartyConfig.Provider>> providerMap =
ThirdPartyProviderSQLHelper.selectAll(
start, providerClientsMap);
start, providerClientsMap);

// Map (tenantIdentifier) -> firstFactors
HashMap<TenantIdentifier, String[]> firstFactorsMap = MfaSqlHelper.selectAllFirstFactors(start);

// Map (tenantIdentifier) -> requiredSecondaryFactors
HashMap<TenantIdentifier, String[]> requiredSecondaryFactorsMap =
MfaSqlHelper.selectAllRequiredSecondaryFactors(
start);
start);

return TenantConfigSQLHelper.selectAll(start, providerMap, firstFactorsMap, requiredSecondaryFactorsMap);
} catch (SQLException throwables) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/io/supertokens/multitenancy/Multitenancy.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@
import io.supertokens.pluginInterface.exceptions.InvalidConfigException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.*;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.MultitenancyStorage;
import io.supertokens.pluginInterface.multitenancy.TenantConfig;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateClientTypeException;
import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateTenantException;
import io.supertokens.pluginInterface.multitenancy.exceptions.DuplicateThirdPartyIdException;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.multitenancy.sqlStorage.MultitenancySQLStorage;
import io.supertokens.pluginInterface.multitenancy.TenantConfig;
import io.supertokens.pluginInterface.passwordless.exception.DuplicatePhoneNumberException;
import io.supertokens.pluginInterface.thirdparty.exception.DuplicateThirdPartyUserException;
import io.supertokens.storageLayer.StorageLayer;
Expand Down Expand Up @@ -459,7 +461,7 @@ public static boolean addUserIdToTenant(Main main, TenantIdentifier tenantIdenti
for (String phoneNumber : phoneNumbers) {
AuthRecipeUserInfo[] usersWithSamePhoneNumber =
authRecipeStorage.listPrimaryUsersByPhoneNumber_Transaction(
tenantIdentifier.toAppIdentifier(), con, phoneNumber);
tenantIdentifier.toAppIdentifier(), con, phoneNumber);
for (AuthRecipeUserInfo userWithSamePhoneNumber : usersWithSamePhoneNumber) {
if (userWithSamePhoneNumber.getSupertokensUserId()
.equals(userToAssociate.getSupertokensUserId())) {
Expand Down Expand Up @@ -489,7 +491,7 @@ public static boolean addUserIdToTenant(Main main, TenantIdentifier tenantIdenti
for (LoginMethod.ThirdParty tp : thirdParties) {
AuthRecipeUserInfo[] usersWithSameThirdPartyInfo =
authRecipeStorage.listPrimaryUsersByThirdPartyInfo_Transaction(
tenantIdentifier.toAppIdentifier(), con, tp.id, tp.userId);
tenantIdentifier.toAppIdentifier(), con, tp.id, tp.userId);
for (AuthRecipeUserInfo userWithSameThirdPartyInfo : usersWithSameThirdPartyInfo) {
if (userWithSameThirdPartyInfo.getSupertokensUserId()
.equals(userToAssociate.getSupertokensUserId())) {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/io/supertokens/session/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import io.supertokens.pluginInterface.authRecipe.LoginMethod;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.*;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantConfig;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.session.SessionStorage;
import io.supertokens.pluginInterface.session.noSqlStorage.SessionNoSQLStorage_1;
Expand Down Expand Up @@ -461,7 +463,7 @@ public static SessionInformationHolder getSession(AppIdentifier appIdentifier, M

io.supertokens.pluginInterface.session.noSqlStorage.SessionInfoWithLastUpdated sessionInfo =
sessionStorage
.getSessionInfo_Transaction(accessToken.sessionHandle);
.getSessionInfo_Transaction(accessToken.sessionHandle);

if (sessionInfo == null) {
throw new UnauthorisedException("Session missing in db");
Expand Down Expand Up @@ -686,7 +688,7 @@ private static SessionInformationHolder refreshSessionHelper(
String sessionHandle = refreshTokenInfo.sessionHandle;
io.supertokens.pluginInterface.session.noSqlStorage.SessionInfoWithLastUpdated sessionInfo =
sessionStorage
.getSessionInfo_Transaction(sessionHandle);
.getSessionInfo_Transaction(sessionHandle);

if (sessionInfo == null || sessionInfo.expiry < System.currentTimeMillis()) {
throw new UnauthorisedException("Session missing in db or has expired");
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/io/supertokens/thirdparty/ThirdParty.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import io.supertokens.pluginInterface.emailverification.sqlStorage.EmailVerificationSQLStorage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.*;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantConfig;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.ThirdPartyConfig;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.thirdparty.exception.DuplicateThirdPartyUserException;
import io.supertokens.pluginInterface.thirdparty.exception.DuplicateUserIdException;
import io.supertokens.pluginInterface.thirdparty.sqlStorage.ThirdPartySQLStorage;
Expand Down Expand Up @@ -271,9 +273,9 @@ private static SignInUpResponse signInUpHelper(TenantIdentifier tenantIdentifier

AuthRecipeUserInfo[] usersFromDb1 =
authRecipeStorage.listPrimaryUsersByThirdPartyInfo_Transaction(
appIdentifier,
con,
thirdPartyId, thirdPartyUserId);
appIdentifier,
con,
thirdPartyId, thirdPartyUserId);
for (AuthRecipeUserInfo user : usersFromDb1) {
if (user.tenantIds.contains(tenantIdentifier.getTenantId())) {
if (userFromDb1 != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public static io.supertokens.pluginInterface.useridmapping.UserIdMapping getUser

io.supertokens.pluginInterface.useridmapping.UserIdMapping[] userIdMappings =
uidMappingStorage.getUserIdMapping_Transaction(
con, appIdentifier, userId);
con, appIdentifier, userId);

if (userIdMappings.length == 0) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import io.supertokens.StorageAndUserIdMapping;
import io.supertokens.emailverification.EmailVerification;
import io.supertokens.multitenancy.exception.BadPermissionException;
import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.useridmapping.UserIdType;
import io.supertokens.utils.Utils;
import io.supertokens.webserver.InputParser;
Expand Down Expand Up @@ -63,7 +63,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I
try {
StorageAndUserIdMapping storageAndUidMapping =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = storageAndUidMapping.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import io.supertokens.emailverification.User;
import io.supertokens.emailverification.exception.EmailVerificationInvalidTokenException;
import io.supertokens.multitenancy.exception.BadPermissionException;
import io.supertokens.output.Logging;
import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.output.Logging;
import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.useridmapping.UserIdType;
import io.supertokens.utils.Utils;
import io.supertokens.webserver.InputParser;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws Servl
try {
StorageAndUserIdMapping storageAndUserIdMapping =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = storageAndUserIdMapping.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I
// Try to find the appIdentifier with right storage based on the userId
StorageAndUserIdMapping storageAndUserIdMapping =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = storageAndUserIdMapping.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
// Try to find the appIdentifier with right storage based on the userId
StorageAndUserIdMapping storageAndUserIdMapping =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = storageAndUserIdMapping.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I
try {
StorageAndUserIdMapping mappingAndStorage =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = mappingAndStorage.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws I
// Try to find the appIdentifier with right storage based on the userId
StorageAndUserIdMapping storageAndUserIdMapping =
enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
storage = storageAndUserIdMapping.storage;
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import io.supertokens.Main;
import io.supertokens.StorageAndUserIdMapping;
import io.supertokens.multitenancy.exception.BadPermissionException;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.pluginInterface.RECIPE_ID;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.useridmapping.UserIdType;
import io.supertokens.usermetadata.UserMetadata;
import io.supertokens.webserver.InputParser;
Expand Down Expand Up @@ -59,7 +59,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
try {
StorageAndUserIdMapping storageAndUserIdMapping =
this.enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
metadata = UserMetadata.getUserMetadata(appIdentifier, storageAndUserIdMapping.storage, userId);
} catch (UnknownUserIdException e) {
throw new IllegalStateException("should never happen");
Expand Down Expand Up @@ -88,7 +88,7 @@ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IO
try {
StorageAndUserIdMapping storageAndUserIdMapping =
this.enforcePublicTenantAndGetStorageAndUserIdMappingForAppSpecificApi(
req, userId, UserIdType.ANY, false);
req, userId, UserIdType.ANY, false);
metadata = UserMetadata.updateUserMetadata(appIdentifier, storageAndUserIdMapping.storage, userId,
update);
} catch (UnknownUserIdException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ public void testUserIdFromDifferentAppIsAllowedForUserIdMapping() throws Excepti
} catch (HttpResponseException e) {
assertEquals(400, e.statusCode);
assertEquals(
"Http error. Status Code: 400. Message: Cannot create a userId mapping where the externalId is also a SuperTokens userID",
"Http error. Status Code: 400. Message: Cannot create a userId mapping where the externalId is " +
"also a SuperTokens userID",
e.getMessage());
}
}
Expand Down

0 comments on commit b4cdd5a

Please sign in to comment.