Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5530d00
adds interface for multi tenancy
rishabhpoddar Jan 16, 2023
094f02d
changes storage layer to take json instead of config file path
rishabhpoddar Jan 19, 2023
ef6a9cc
adds new interface to indentify a user pool
rishabhpoddar Jan 19, 2023
fa8af13
exception throwing change
rishabhpoddar Jan 19, 2023
faebf7a
adds function to get connection pool ID
rishabhpoddar Jan 23, 2023
102596d
changes to interface
rishabhpoddar Jan 23, 2023
daa1089
changes to initstorage interface function
rishabhpoddar Jan 24, 2023
c4efd7d
adds function so that the core can create multiple user pools during …
rishabhpoddar Jan 28, 2023
b285355
adds tenantidentifier class
rishabhpoddar Feb 5, 2023
1227497
adds more functions to interface
rishabhpoddar Feb 7, 2023
9eacc1e
removes unused exception
rishabhpoddar Feb 7, 2023
ee8993f
small change
rishabhpoddar Feb 8, 2023
6e100b8
adds new functions
rishabhpoddar Feb 8, 2023
b7b1b50
adds deletion functions for multitenancy
rishabhpoddar Feb 9, 2023
acb2b3f
few changes
rishabhpoddar Feb 9, 2023
8bde555
updates exception class
rishabhpoddar Feb 9, 2023
75f54a5
simplifies delete of app and connectionuridomain
rishabhpoddar Feb 10, 2023
d1755a4
adds getters for certain tenant config props
rishabhpoddar Feb 11, 2023
ac4af09
adds equals functions for tenantconfig types
rishabhpoddar Feb 12, 2023
2425d18
adds constructors for thirdparty config objects
rishabhpoddar Feb 12, 2023
efac642
changes equals for tenantconfig
rishabhpoddar Feb 12, 2023
18dcc9a
removes nullable annotation from primitive type
rishabhpoddar Feb 12, 2023
d402f2d
adds tenantIdentifier for emailpassword and useridmapping recipes
rishabhpoddar Feb 13, 2023
0b15606
adds extra comment
rishabhpoddar Feb 13, 2023
2a4c598
adds comment
rishabhpoddar Feb 13, 2023
54e2a29
changes to incorporate tenantIndetifier for key value storage
rishabhpoddar Feb 14, 2023
dfb9363
changes to session receipe to add tenantIdentifier
rishabhpoddar Feb 14, 2023
0874036
introduces the concept of appIdentifier vs tenantIdentifier
rishabhpoddar Feb 15, 2023
01bf511
adds a few more functions
rishabhpoddar Feb 15, 2023
556e3cd
adds appidentifier to user metadata functions
rishabhpoddar Feb 15, 2023
49eba24
modifes user roles functions to add tenantidentifier and appidentifiers
rishabhpoddar Feb 15, 2023
3b4a43f
changes to emailpassword functions
rishabhpoddar Feb 16, 2023
6c201e9
changes to a few functions
rishabhpoddar Feb 17, 2023
d0071ed
adds appidentifier to email verfication
rishabhpoddar Feb 17, 2023
d08a59b
adds tenant identifier to third party
rishabhpoddar Feb 17, 2023
ac6c099
adds tenantidentifier to passwordless
rishabhpoddar Feb 17, 2023
976362f
function name changes
rishabhpoddar Feb 20, 2023
a36b7f6
fix: changes for multi-tenancy impl (#55)
sattvikc Feb 24, 2023
2018b3d
fix: new exceptions (#56)
sattvikc Feb 28, 2023
dcd6e96
fix: changes for random test (#57)
sattvikc Mar 2, 2023
d7c62eb
Merge branch '2.20' into multi-tenant-config
rishabhpoddar Mar 5, 2023
9b9e228
makes dashboard interface per app
rishabhpoddar Mar 5, 2023
0a1ee4b
fix: storage in AppIdentifier and TenantIdentifier (#61)
sattvikc Mar 24, 2023
35d7cde
fix: fixed pless interface (#64)
sattvikc Mar 24, 2023
0ad9103
fix: to support PR comments on core (#65)
sattvikc Mar 25, 2023
546af6a
fix: added storages to appIdentifierWithStorage (#66)
sattvikc Mar 27, 2023
d6dc7e0
fix: Multitenant userroles (#67)
sattvikc Mar 28, 2023
a9d7e0f
fix: Multitenant usermetadata (#68)
sattvikc Mar 29, 2023
77cf4f3
fix: ep storage (#69)
sattvikc Mar 29, 2023
32ff39d
fix: Multitenant uidmapping storage (#70)
sattvikc Mar 29, 2023
c91dd33
fix: Multitenant passwordless storage (#71)
sattvikc Mar 31, 2023
05cba25
fix: thirdparty storage (#72)
sattvikc Mar 31, 2023
2e97a56
fix: Multitenant thirdparty changes for update email (#73)
sattvikc Apr 1, 2023
16a9f58
fix: Multitenant emailverification storage (#74)
sattvikc Apr 3, 2023
6b01058
fix: making tokens tenant specific (#75)
sattvikc Apr 3, 2023
7acf7f5
comment modification
rishabhpoddar Apr 5, 2023
03bd13a
fix: Multitenant session (#76)
sattvikc Apr 5, 2023
a93b6b9
fix: adding tenant or app not found exceptions
sattvikc Apr 5, 2023
7d9a133
merges with latest (#77)
rishabhpoddar Apr 5, 2023
0c16056
small change
rishabhpoddar Apr 6, 2023
89bc5f7
fix: jwt changes (#78)
sattvikc Apr 6, 2023
c072fa6
fix: Multitenant Authrecipe changes (#79)
sattvikc Apr 7, 2023
525e80c
fix: Multitenant dashboard (#80)
sattvikc Apr 10, 2023
566f5a8
fix: Multitenant totp (#81)
sattvikc Apr 11, 2023
7019947
merges (#82)
rishabhpoddar Apr 13, 2023
155aa16
adds new config (#83)
rishabhpoddar Apr 18, 2023
3cd30ed
fix: multitenancy changes (#84)
sattvikc Apr 20, 2023
a67d94d
fix: base tenant (#85)
sattvikc Apr 25, 2023
a8537c8
fix: Tenantid in userobjects (#86)
sattvikc Apr 27, 2023
b41dd3b
fix: tenant id in loadConfig (#88)
sattvikc Apr 28, 2023
9b6a415
fix: delete non auth user (#89)
sattvikc May 2, 2023
dcd65c5
fix: nonAuthRecipeuserData to take tenantIdentifier (#90)
sattvikc May 4, 2023
9a9265b
fix: pr comment
sattvikc May 4, 2023
5b95fad
fix: config validation (#91)
sattvikc May 4, 2023
1f0b25f
fix: reload resources (#93)
sattvikc May 11, 2023
eec65fa
fix: added setLogLevels (#95)
sattvikc May 15, 2023
3e37980
fix: Active user storage to extend NonAuthRecipeStorage (#97)
sattvikc May 25, 2023
db406a0
Merge branch '2.23' into multi-tenant-config
sattvikc Jun 2, 2023
032f74a
fix: version update
sattvikc Jun 2, 2023
1c12bb6
fix: jar
sattvikc Jun 2, 2023
f130661
fix: jar
sattvikc Jun 2, 2023
c99f435
fix: version update
sattvikc Jun 2, 2023
d239acf
fix: update version
sattvikc Jun 2, 2023
be1e351
fix: added date
sattvikc Jun 2, 2023
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.0.0] - 2023-06-02

- Adds support for multi-tenancy

## [2.23.0] - 2023-04-05

- Added `useStaticKey ` into session info classes
Expand Down Expand Up @@ -109,4 +113,4 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Added RowMapper interface for db queries
- Email verification related changes
- User pagination related queries
- User pagination related queries
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "2.23.0"
version = "3.0.0"

repositories {
mavenCentral()
Expand Down
Binary file removed jar/plugin-interface-2.23.0.jar
Binary file not shown.
Binary file added jar/plugin-interface-3.0.0.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package io.supertokens.pluginInterface;

import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.nonAuthRecipe.NonAuthRecipeStorage;

public interface ActiveUsersStorage extends Storage {
public interface ActiveUsersStorage extends NonAuthRecipeStorage {
/* Update the last active time of a user to now */
void updateLastActive(String userId) throws StorageQueryException;
void updateLastActive(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

/* Count the number of users who did some activity after given timestamp */
int countUsersActiveSince(long time) throws StorageQueryException;
int countUsersActiveSince(AppIdentifier appIdentifier, long time) throws StorageQueryException;

/* Count the number of users who have enabled TOTP */
int countUsersEnabledTotp() throws StorageQueryException;
int countUsersEnabledTotp(AppIdentifier appIdentifier) throws StorageQueryException;

/* Count the number of users who have enabled TOTP and are active */
int countUsersEnabledTotpAndActiveSince(long time) throws StorageQueryException;
int countUsersEnabledTotpAndActiveSince(AppIdentifier appIdentifier, long time) throws StorageQueryException;

void deleteUserActive(AppIdentifier appIdentifier, String userId) throws StorageQueryException;
}
3 changes: 2 additions & 1 deletion src/main/java/io/supertokens/pluginInterface/RECIPE_ID.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum RECIPE_ID {

EMAIL_PASSWORD("emailpassword"), THIRD_PARTY("thirdparty"), SESSION("session"),
EMAIL_VERIFICATION("emailverification"), JWT("jwt"), PASSWORDLESS("passwordless"), USER_METADATA("usermetadata"),
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping"), DASHBOARD("dashboard"), TOTP("totp");
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping"), DASHBOARD("dashboard"), TOTP("totp"),
MULTITENANCY("multitenancy");

private final String name;

Expand Down
46 changes: 39 additions & 7 deletions src/main/java/io/supertokens/pluginInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@

package io.supertokens.pluginInterface;

import com.google.gson.JsonObject;
import io.supertokens.pluginInterface.exceptions.DbInitException;
import io.supertokens.pluginInterface.exceptions.InvalidConfigException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

import java.util.Set;

Expand All @@ -26,14 +32,27 @@ public interface Storage {
// if silent is true, do not log anything out on the console
void constructor(String processId, boolean silent);

void loadConfig(String configFilePath, Set<LOG_LEVEL> logLevels);
void loadConfig(JsonObject jsonConfig, Set<LOG_LEVEL> logLevels, TenantIdentifier tenantIdentifier) throws InvalidConfigException;

// this returns a unique ID based on the db's connection URI and table prefix such that
// two different user pool IDs imply that the data for those two user pools are completely isolated.
String getUserPoolId();

// this returns a unique ID based on the db's connection pool config. This can be different
// even if the getUserPoolId returns the same ID - based on the config provided by the user.
// So two different db connection pools may point to the same end user pool.
String getConnectionPoolId();

// if the input otherConfig has different values set for the same properties as this user pool's config,
// then this function should throw an error since this is a misconfig from ther user's side.
void assertThatConfigFromSameUserPoolIsNotConflicting(JsonObject otherConfig) throws InvalidConfigException;

void initFileLogging(String infoLogPath, String errorLogPath);

void stopLogging();

// load tables and create connection pools
void initStorage();
void initStorage(boolean shouldWait) throws DbInitException;

// used by the core to do transactions the right way.
STORAGE_TYPE getType();
Expand All @@ -43,19 +62,32 @@ public interface Storage {

void close();

KeyValueInfo getKeyValue(String key) throws StorageQueryException;
KeyValueInfo getKeyValue(TenantIdentifier tenantIdentifier, String key) throws StorageQueryException;

void setKeyValue(String key, KeyValueInfo info) throws StorageQueryException;
void setKeyValue(TenantIdentifier tenantIdentifier, String key, KeyValueInfo info) throws StorageQueryException,
TenantOrAppNotFoundException;

void setStorageLayerEnabled(boolean enabled);

boolean canBeUsed(String configFilePath);
boolean canBeUsed(JsonObject configJson);

// this function will be used in the createUserIdMapping and deleteUserIdMapping functions to check if the userId is
// being used in NonAuth recipes.
boolean isUserIdBeingUsedInNonAuthRecipe(String className, String userId) throws StorageQueryException;
boolean isUserIdBeingUsedInNonAuthRecipe(AppIdentifier appIdentifier, String className, String userId)
throws StorageQueryException;

// to be used for testing purposes only. This function will add dummy data to non-auth tables.
void addInfoToNonAuthRecipesBasedOnUserId(String className, String userId) throws StorageQueryException;
void addInfoToNonAuthRecipesBasedOnUserId(TenantIdentifier tenantIdentifier, String className, String userId) throws StorageQueryException;

// this function is used during testing in the core so that the core can
// create multiple user pools across any plugin being used.
void modifyConfigToAddANewUserPoolForTesting(JsonObject config, int poolNumber);

// this function returns a list of protected configs which users of supertokens saas can't read or modify
// when they are operating on tenantsm unless the supertokens_saas_secret key is used in the API request.
String[] getProtectedConfigsFromSuperTokensSaaSUsers();

Set<String> getValidFieldsInConfig();

void setLogLevels(Set<LOG_LEVEL> logLevels);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,27 @@
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.dashboard.DashboardSearchTags;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface AuthRecipeStorage extends Storage {

long getUsersCount(@Nullable RECIPE_ID[] includeRecipeIds) throws StorageQueryException;
long getUsersCount(TenantIdentifier tenantIdentifier, @Nullable RECIPE_ID[] includeRecipeIds)
throws StorageQueryException;

long getUsersCount(AppIdentifier appIdentifier, @Nullable RECIPE_ID[] includeRecipeIds)
throws StorageQueryException;

AuthRecipeUserInfo[] getUsers(@Nonnull Integer limit, @Nonnull String timeJoinedOrder,
@Nullable RECIPE_ID[] includeRecipeIds, @Nullable String userId, @Nullable Long timeJoined, @Nullable DashboardSearchTags dashboardSearchTags)
AuthRecipeUserInfo[] getUsers(TenantIdentifier tenantIdentifier, @Nonnull Integer limit,
@Nonnull String timeJoinedOrder,
@Nullable RECIPE_ID[] includeRecipeIds, @Nullable String userId,
@Nullable Long timeJoined, @Nullable DashboardSearchTags dashboardSearchTags)
throws StorageQueryException;

boolean doesUserIdExist(String userId) throws StorageQueryException;
boolean doesUserIdExist(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

boolean doesUserIdExist(TenantIdentifier tenantIdentifierIdentifier, String userId) throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ public abstract class AuthRecipeUserInfo {

public long timeJoined;

public AuthRecipeUserInfo(String id, long timeJoined) {
public final String[] tenantIds;

public AuthRecipeUserInfo(String id, long timeJoined, String[] tenantIds) {
this.id = id;
this.timeJoined = timeJoined;
this.tenantIds = tenantIds;
}

public abstract RECIPE_ID getRecipeId();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
package io.supertokens.pluginInterface.dashboard;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateUserIdException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

public interface DashboardStorage extends Storage {

void createNewDashboardUser(DashboardUser userInfo) throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException;
void createNewDashboardUser(AppIdentifier appIdentifier, DashboardUser userInfo)
throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException,
TenantOrAppNotFoundException;

DashboardUser getDashboardUserByEmail(AppIdentifier appIdentifier, String email) throws StorageQueryException;

DashboardUser getDashboardUserByEmail(String email) throws StorageQueryException;
DashboardUser getDashboardUserByUserId(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

DashboardUser getDashboardUserByUserId(String userId) throws StorageQueryException;
DashboardUser[] getAllDashboardUsers(AppIdentifier appIdentifier) throws StorageQueryException;

DashboardUser[] getAllDashboardUsers() throws StorageQueryException;
boolean deleteDashboardUserWithUserId(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

boolean deleteDashboardUserWithUserId(String userId) throws StorageQueryException;

void createNewDashboardUserSession(String userId, String sessionId, long timeCreated, long expiry) throws StorageQueryException, UserIdNotFoundException;
void createNewDashboardUserSession(AppIdentifier appIdentifier, String userId, String sessionId, long timeCreated,
long expiry) throws StorageQueryException, UserIdNotFoundException;

DashboardSessionInfo[] getAllSessionsForUserId(String userId) throws StorageQueryException;
DashboardSessionInfo[] getAllSessionsForUserId(AppIdentifier appIdentifier, String userId)
throws StorageQueryException;

DashboardSessionInfo getSessionInfoWithSessionId(String sessionId) throws StorageQueryException;
DashboardSessionInfo getSessionInfoWithSessionId(AppIdentifier appIdentifier, String sessionId)
throws StorageQueryException;

boolean revokeSessionWithSessionId(String sessionId) throws StorageQueryException;
boolean revokeSessionWithSessionId(AppIdentifier appIdentifier, String sessionId) throws StorageQueryException;

// this function removes based on expired time, so we can use this to globally remove from a particular db.
void revokeExpiredSessions() throws StorageQueryException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.sqlStorage.SQLStorage;
import io.supertokens.pluginInterface.sqlStorage.TransactionConnection;

public interface DashboardSQLStorage extends DashboardStorage, SQLStorage {

void updateDashboardUsersEmailWithUserId_Transaction(TransactionConnection con, String userId, String newEmail) throws StorageQueryException, DuplicateEmailException, UserIdNotFoundException;
void updateDashboardUsersEmailWithUserId_Transaction(AppIdentifier appIdentifier, TransactionConnection con,
String userId, String newEmail)
throws StorageQueryException, DuplicateEmailException, UserIdNotFoundException;

void updateDashboardUsersPasswordWithUserId_Transaction(AppIdentifier appIdentifier, TransactionConnection con,
String userId, String newPassword)
throws StorageQueryException, UserIdNotFoundException;

void updateDashboardUsersPasswordWithUserId_Transaction(TransactionConnection con, String userId, String newPassword) throws StorageQueryException, UserIdNotFoundException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,39 @@
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateUserIdException;
import io.supertokens.pluginInterface.emailpassword.exceptions.UnknownUserIdException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;

import javax.annotation.Nonnull;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.TenantIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;

public interface EmailPasswordStorage extends AuthRecipeStorage {

void signUp(UserInfo userInfo) throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException;

void deleteEmailPasswordUser(String userId) throws StorageQueryException;
// we pass tenantIdentifier here cause this also adds to the userId <-> tenantId mapping
UserInfo signUp(TenantIdentifier tenantIdentifier, String id, String email, String passwordHash, long timeJoined)
throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException,
TenantOrAppNotFoundException;

UserInfo getUserInfoUsingId(String id) throws StorageQueryException;
// this deletion of a user is app wide since the same user ID can be shared across tenants
void deleteEmailPasswordUser(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

UserInfo getUserInfoUsingId(AppIdentifier appIdentifier, String id) throws StorageQueryException;

UserInfo getUserInfoUsingEmail(String email) throws StorageQueryException;
// Here we pass in TenantIdentifier cause the same email can be shared across tenants, but yield different
// user IDs
UserInfo getUserInfoUsingEmail(TenantIdentifier tenantIdentifier, String email) throws StorageQueryException;

void addPasswordResetToken(PasswordResetTokenInfo passwordResetTokenInfo)
// password reset stuff is app wide cause changing the password for a user affects all the tenants
// across which it's shared.
void addPasswordResetToken(AppIdentifier appIdentifier, PasswordResetTokenInfo passwordResetTokenInfo)
throws StorageQueryException, UnknownUserIdException, DuplicatePasswordResetTokenException;

PasswordResetTokenInfo getPasswordResetTokenInfo(String token) throws StorageQueryException;
PasswordResetTokenInfo getPasswordResetTokenInfo(AppIdentifier appIdentifier, String token)
throws StorageQueryException;

// we purposely do not add TenantIdentifier to this query cause
// this is called from a cronjob that runs per user pool ID
void deleteExpiredPasswordResetTokens() throws StorageQueryException;

PasswordResetTokenInfo[] getAllPasswordResetTokenInfoForUser(String userId) throws StorageQueryException;

@Deprecated
UserInfo[] getUsers(@Nonnull String userId, @Nonnull Long timeJoined, @Nonnull Integer limit,
@Nonnull String timeJoinedOrder) throws StorageQueryException;

@Deprecated
UserInfo[] getUsers(@Nonnull Integer limit, @Nonnull String timeJoinedOrder) throws StorageQueryException;

@Deprecated
long getUsersCount() throws StorageQueryException;
PasswordResetTokenInfo[] getAllPasswordResetTokenInfoForUser(AppIdentifier appIdentifier, String userId)
throws StorageQueryException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class UserInfo extends AuthRecipeUserInfo {
// using transient, we tell Gson not to include this when creating a JSON
public transient final String passwordHash;

public UserInfo(String id, String email, String passwordHash, long timeJoined) {
super(id, timeJoined);
public UserInfo(String id, String email, String passwordHash, long timeJoined, String[] tenantIds) {
super(id, timeJoined, tenantIds);
this.email = email;
this.passwordHash = passwordHash;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,31 @@
import io.supertokens.pluginInterface.emailpassword.UserInfo;
import io.supertokens.pluginInterface.emailpassword.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.sqlStorage.SQLStorage;
import io.supertokens.pluginInterface.sqlStorage.TransactionConnection;

public interface EmailPasswordSQLStorage extends EmailPasswordStorage, SQLStorage {

PasswordResetTokenInfo[] getAllPasswordResetTokenInfoForUser_Transaction(TransactionConnection con, String userId)
// all password reset related stuff is app wide cause the same user ID can be shared across tenants,
// and updating / resetting a user's password should apply to all those tenants.

PasswordResetTokenInfo[] getAllPasswordResetTokenInfoForUser_Transaction(AppIdentifier appIdentifier,
TransactionConnection con, String userId)
throws StorageQueryException;

void deleteAllPasswordResetTokensForUser_Transaction(TransactionConnection con, String userId)
void deleteAllPasswordResetTokensForUser_Transaction(AppIdentifier appIdentifier, TransactionConnection con,
String userId)
throws StorageQueryException;

void updateUsersPassword_Transaction(TransactionConnection con, String userId, String newPassword)
void updateUsersPassword_Transaction(AppIdentifier appIdentifier, TransactionConnection con, String userId,
String newPassword)
throws StorageQueryException;

void updateUsersEmail_Transaction(TransactionConnection conn, String userId, String email)
void updateUsersEmail_Transaction(AppIdentifier appIdentifier, TransactionConnection conn, String userId,
String email)
throws StorageQueryException, DuplicateEmailException;

UserInfo getUserInfoUsingId_Transaction(TransactionConnection con, String userId) throws StorageQueryException;
UserInfo getUserInfoUsingId_Transaction(AppIdentifier appIdentifier, TransactionConnection con, String userId)
throws StorageQueryException;
}
Loading