Skip to content

Commit

Permalink
fix: remove UserInfo class (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc authored Aug 26, 2023
1 parent 1f43f89 commit dc61ea9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/main/java/io/supertokens/storage/postgresql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.dashboard.sqlStorage.DashboardSQLStorage;
import io.supertokens.pluginInterface.emailpassword.PasswordResetTokenInfo;
import io.supertokens.pluginInterface.emailpassword.UserInfo;
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicatePasswordResetTokenException;
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateUserIdException;
Expand Down Expand Up @@ -871,7 +870,7 @@ public String[] getProtectedConfigsFromSuperTokensSaaSUsers() {
}

@Override
public UserInfo signUp(TenantIdentifier tenantIdentifier, String id, String email, String passwordHash,
public AuthRecipeUserInfo signUp(TenantIdentifier tenantIdentifier, String id, String email, String passwordHash,
long timeJoined)
throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException,
TenantOrAppNotFoundException {
Expand Down Expand Up @@ -1204,7 +1203,7 @@ public void updateUserEmail_Transaction(AppIdentifier appIdentifier, Transaction
}

@Override
public io.supertokens.pluginInterface.thirdparty.UserInfo signUp(
public AuthRecipeUserInfo signUp(
TenantIdentifier tenantIdentifier, String id, String email,
LoginMethod.ThirdParty thirdParty, long timeJoined)
throws StorageQueryException, io.supertokens.pluginInterface.thirdparty.exception.DuplicateUserIdException,
Expand Down Expand Up @@ -1717,7 +1716,7 @@ public void createCode(TenantIdentifier tenantIdentifier, PasswordlessCode code)
}

@Override
public io.supertokens.pluginInterface.passwordless.UserInfo createUser(TenantIdentifier tenantIdentifier,
public AuthRecipeUserInfo createUser(TenantIdentifier tenantIdentifier,
String id,
@javax.annotation.Nullable String email,
@javax.annotation.Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package io.supertokens.storage.postgresql.queries;

import io.supertokens.pluginInterface.RowMapper;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo;
import io.supertokens.pluginInterface.authRecipe.LoginMethod;
import io.supertokens.pluginInterface.emailpassword.PasswordResetTokenInfo;
import io.supertokens.pluginInterface.emailpassword.UserInfo;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
Expand Down Expand Up @@ -263,8 +263,8 @@ public static void addPasswordResetToken(Start start, AppIdentifier appIdentifie
}
}

public static UserInfo signUp(Start start, TenantIdentifier tenantIdentifier, String userId, String email,
String passwordHash, long timeJoined)
public static AuthRecipeUserInfo signUp(Start start, TenantIdentifier tenantIdentifier, String userId, String email,
String passwordHash, long timeJoined)
throws StorageQueryException, StorageTransactionLogicException {
return start.startTransaction(con -> {
Connection sqlCon = (Connection) con.getConnection();
Expand Down Expand Up @@ -323,7 +323,7 @@ public static UserInfo signUp(Start start, TenantIdentifier tenantIdentifier, St
fillUserInfoWithTenantIds_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
fillUserInfoWithVerified_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
sqlCon.commit();
return new UserInfo(userId, false, userInfo.toLoginMethod());
return AuthRecipeUserInfo.create(userId, false, userInfo.toLoginMethod());
} catch (SQLException throwables) {
throw new StorageTransactionLogicException(throwables);
}
Expand Down Expand Up @@ -565,7 +565,7 @@ private static List<UserInfoPartial> fillUserInfoWithTenantIds_transaction(Start
Map<String, List<String>> tenantIdsForUserIds = GeneralQueries.getTenantIdsForUserIds_transaction(start, sqlCon,
appIdentifier,
userIds);
List<UserInfo> result = new ArrayList<>();
List<AuthRecipeUserInfo> result = new ArrayList<>();
for (UserInfoPartial userInfo : userInfos) {
userInfo.tenantIds = tenantIdsForUserIds.get(userInfo.id).toArray(new String[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package io.supertokens.storage.postgresql.queries;

import io.supertokens.pluginInterface.RowMapper;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo;
import io.supertokens.pluginInterface.authRecipe.LoginMethod;
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.passwordless.PasswordlessCode;
import io.supertokens.pluginInterface.passwordless.PasswordlessDevice;
import io.supertokens.pluginInterface.passwordless.UserInfo;
import io.supertokens.pluginInterface.sqlStorage.SQLStorage.TransactionIsolationLevel;
import io.supertokens.storage.postgresql.ConnectionPool;
import io.supertokens.storage.postgresql.Start;
Expand Down Expand Up @@ -387,8 +387,8 @@ public static void deleteCode_Transaction(Start start, Connection con, TenantIde
});
}

public static UserInfo createUser(Start start, TenantIdentifier tenantIdentifier, String id, @Nullable String email,
@Nullable String phoneNumber, long timeJoined)
public static AuthRecipeUserInfo createUser(Start start, TenantIdentifier tenantIdentifier, String id, @Nullable String email,
@Nullable String phoneNumber, long timeJoined)
throws StorageTransactionLogicException, StorageQueryException {
return start.startTransaction(con -> {
Connection sqlCon = (Connection) con.getConnection();
Expand Down Expand Up @@ -446,7 +446,7 @@ public static UserInfo createUser(Start start, TenantIdentifier tenantIdentifier
fillUserInfoWithTenantIds_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
fillUserInfoWithVerified_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
sqlCon.commit();
return new UserInfo(id, false,
return AuthRecipeUserInfo.create(id, false,
userInfo.toLoginMethod());
} catch (SQLException throwables) {
throw new StorageTransactionLogicException(throwables);
Expand Down Expand Up @@ -957,7 +957,7 @@ private static List<UserInfoPartial> fillUserInfoWithTenantIds_transaction(Start
Map<String, List<String>> tenantIdsForUserIds = GeneralQueries.getTenantIdsForUserIds_transaction(start, sqlCon,
appIdentifier,
userIds);
List<UserInfo> result = new ArrayList<>();
List<AuthRecipeUserInfo> result = new ArrayList<>();
for (UserInfoPartial userInfo : userInfos) {
userInfo.tenantIds = tenantIdsForUserIds.get(userInfo.id).toArray(new String[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package io.supertokens.storage.postgresql.queries;

import io.supertokens.pluginInterface.RowMapper;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo;
import io.supertokens.pluginInterface.authRecipe.LoginMethod;
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.thirdparty.UserInfo;
import io.supertokens.storage.postgresql.Start;
import io.supertokens.storage.postgresql.config.Config;
import io.supertokens.storage.postgresql.utils.Utils;
Expand Down Expand Up @@ -94,8 +94,8 @@ static String getQueryToCreateThirdPartyUserToTenantTable(Start start) {
// @formatter:on
}

public static UserInfo signUp(Start start, TenantIdentifier tenantIdentifier, String id, String email,
LoginMethod.ThirdParty thirdParty, long timeJoined)
public static AuthRecipeUserInfo signUp(Start start, TenantIdentifier tenantIdentifier, String id, String email,
LoginMethod.ThirdParty thirdParty, long timeJoined)
throws StorageQueryException, StorageTransactionLogicException {
return start.startTransaction(con -> {
Connection sqlCon = (Connection) con.getConnection();
Expand Down Expand Up @@ -156,7 +156,7 @@ public static UserInfo signUp(Start start, TenantIdentifier tenantIdentifier, St
fillUserInfoWithTenantIds_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
fillUserInfoWithVerified_transaction(start, sqlCon, tenantIdentifier.toAppIdentifier(), userInfo);
sqlCon.commit();
return new UserInfo(id, false, userInfo.toLoginMethod());
return AuthRecipeUserInfo.create(id, false, userInfo.toLoginMethod());

} catch (SQLException throwables) {
throw new StorageTransactionLogicException(throwables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.supertokens.multitenancy.exception.BadPermissionException;
import io.supertokens.multitenancy.exception.CannotModifyBaseConfigException;
import io.supertokens.pluginInterface.authRecipe.AuthRecipeUserInfo;
import io.supertokens.pluginInterface.emailpassword.UserInfo;
import io.supertokens.pluginInterface.exceptions.InvalidConfigException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.*;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void testUsersWorkAfterUserPoolIdChanges() throws Exception {

String userPoolId = tenantIdentifierWithStorage.getStorage().getUserPoolId();

UserInfo userInfo = EmailPassword.signUp(
AuthRecipeUserInfo userInfo = EmailPassword.signUp(
tenantIdentifierWithStorage, process.getProcess(), "user@example.com", "password");

coreConfig.addProperty("postgresql_host", "127.0.0.1");
Expand Down Expand Up @@ -136,7 +135,7 @@ public void testUsersWorkAfterUserPoolIdChangesAndServerRestart() throws Excepti

String userPoolId = tenantIdentifierWithStorage.getStorage().getUserPoolId();

UserInfo userInfo = EmailPassword.signUp(
AuthRecipeUserInfo userInfo = EmailPassword.signUp(
tenantIdentifierWithStorage, process.getProcess(), "user@example.com", "password");

coreConfig.addProperty("postgresql_host", "127.0.0.1");
Expand Down

0 comments on commit dc61ea9

Please sign in to comment.