Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove UserInfo class #148

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading