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: fixes storage handling for non-auth recipes #942

Merged
merged 31 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eb4496b
fix: non auth recipe stuff
sattvikc Feb 29, 2024
d267312
fix: user roles
sattvikc Feb 29, 2024
6b2a45c
fix: half done
sattvikc Mar 1, 2024
fadf205
fix: thirdparty changes
sattvikc Mar 1, 2024
9a0ff85
fix: passwordless changes
sattvikc Mar 1, 2024
89fd936
fix: active users
sattvikc Mar 1, 2024
458c3b6
fix: session changes
sattvikc Mar 1, 2024
9eb76a1
fix: user metadata
sattvikc Mar 1, 2024
4843083
fix: user roles
sattvikc Mar 1, 2024
69a2466
fix: totp
sattvikc Mar 1, 2024
6728665
fix: email verification
sattvikc Mar 1, 2024
c61c7d7
fix: multitenancy and other minor fixes
sattvikc Mar 1, 2024
c1edaba
fix: compile errors
sattvikc Mar 1, 2024
dd688da
fix: bugs and tests
sattvikc Mar 1, 2024
c5fc6a3
fix: bugs and tests
sattvikc Mar 1, 2024
5f00b5e
fix: func rename
sattvikc Mar 1, 2024
311b9b0
fix: PR comments
sattvikc Mar 4, 2024
75b5a14
fix: pr comments
sattvikc Mar 4, 2024
38c11fd
fix: pr comments
sattvikc Mar 4, 2024
06569c0
fix: pr comments
sattvikc Mar 4, 2024
d94a381
fix: user role multitenant tests
sattvikc Mar 4, 2024
83b802c
fix: email verification tests
sattvikc Mar 4, 2024
3d93ab5
fix: user role deletion
sattvikc Mar 4, 2024
d7cbcfa
fix: user roles
sattvikc Mar 4, 2024
fb2234c
fix: user roles
sattvikc Mar 4, 2024
8945be1
fix: get tenant identifier refactor
sattvikc Mar 4, 2024
a5d7aad
fix: pr comments
sattvikc Mar 4, 2024
88539e5
fix: query
sattvikc Mar 4, 2024
8a31166
fix: tests version and changelog
sattvikc Mar 5, 2024
644b5d6
Update CHANGELOG.md
sattvikc Mar 5, 2024
0bfad8b
fix: pr comments
sattvikc Mar 5, 2024
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
2 changes: 1 addition & 1 deletion ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private JsonObject getMultiTenancyStats()
return stats;
}

private JsonObject getAccountLinkingStats() throws StorageQueryException {
private JsonObject getAccountLinkingStats() throws StorageQueryException, TenantOrAppNotFoundException {
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
JsonObject result = new JsonObject();
Storage[] storages = StorageLayer.getStoragesForApp(main, this.appIdentifier);
boolean usesAccountLinking = false;
Expand Down
29 changes: 16 additions & 13 deletions src/main/java/io/supertokens/ActiveUsers.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
package io.supertokens;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.StorageUtils;
import io.supertokens.pluginInterface.authRecipe.sqlStorage.AuthRecipeSQLStorage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.exceptions.StorageTransactionLogicException;
import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage;
import io.supertokens.pluginInterface.multitenancy.AppIdentifier;
import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException;
import io.supertokens.storageLayer.StorageLayer;
import org.jetbrains.annotations.TestOnly;

public class ActiveUsers {

public static void updateLastActive(AppIdentifierWithStorage appIdentifierWithStorage, Main main, String userId)
public static void updateLastActive(AppIdentifier appIdentifier, Main main, String userId)
throws TenantOrAppNotFoundException {
Storage storage = StorageLayer.getStorage(appIdentifier.getAsPublicTenantIdentifier(), main);
try {
appIdentifierWithStorage.getActiveUsersStorage().updateLastActive(appIdentifierWithStorage, userId);
StorageUtils.getActiveUsersStorage(storage).updateLastActive(appIdentifier, userId);
} catch (StorageQueryException ignored) {
}
}

@TestOnly
public static void updateLastActive(Main main, String userId) {
try {
ActiveUsers.updateLastActive(new AppIdentifierWithStorage(null, null, StorageLayer.getStorage(main)), main,
userId);
ActiveUsers.updateLastActive(new AppIdentifier(null, null),
main, userId);
} catch (TenantOrAppNotFoundException e) {
throw new IllegalStateException(e);
}
}

public static int countUsersActiveSince(AppIdentifierWithStorage appIdentifierWithStorage, Main main, long time)
public static int countUsersActiveSince(AppIdentifier appIdentifier, Storage storage, long time)
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
throws StorageQueryException, TenantOrAppNotFoundException {
return appIdentifierWithStorage.getActiveUsersStorage().countUsersActiveSince(appIdentifierWithStorage, time);
return StorageUtils.getActiveUsersStorage(storage).countUsersActiveSince(appIdentifier, time);
}

@TestOnly
public static int countUsersActiveSince(Main main, long time)
throws StorageQueryException, TenantOrAppNotFoundException {
return countUsersActiveSince(new AppIdentifierWithStorage(null, null, StorageLayer.getStorage(main)), main,
time);
return countUsersActiveSince(new AppIdentifier(null, null),
StorageLayer.getStorage(main), time);
}

public static void removeActiveUser(AppIdentifierWithStorage appIdentifierWithStorage, String userId)
public static void removeActiveUser(AppIdentifier appIdentifier, Storage storage, String userId)
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
throws StorageQueryException {
try {
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).startTransaction(con -> {
appIdentifierWithStorage.getActiveUsersStorage().deleteUserActive_Transaction(con, appIdentifierWithStorage, userId);
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).commitTransaction(con);
((AuthRecipeSQLStorage) StorageUtils.getActiveUsersStorage(storage)).startTransaction(con -> {
StorageUtils.getActiveUsersStorage(storage).deleteUserActive_Transaction(con, appIdentifier, userId);
((AuthRecipeSQLStorage) StorageUtils.getActiveUsersStorage(storage)).commitTransaction(con);
return null;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@

package io.supertokens;

import io.supertokens.pluginInterface.multitenancy.AppIdentifierWithStorage;
import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.useridmapping.UserIdMapping;

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

public class AppIdentifierWithStorageAndUserIdMapping {
public class StorageAndUserIdMapping {
@Nullable
public final io.supertokens.pluginInterface.useridmapping.UserIdMapping userIdMapping;

@Nonnull
public final AppIdentifierWithStorage appIdentifierWithStorage;
public final Storage storage;

public AppIdentifierWithStorageAndUserIdMapping(AppIdentifierWithStorage appIdentifierWithStorage, UserIdMapping userIdMapping) {
this.appIdentifierWithStorage = appIdentifierWithStorage;
public StorageAndUserIdMapping(Storage storage, UserIdMapping userIdMapping) {
this.storage = storage;
this.userIdMapping = userIdMapping;

assert(this.appIdentifierWithStorage != null);
}
}

This file was deleted.

Loading
Loading