-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixes storage handling for non-auth recipes (#942)
* fix: non auth recipe stuff * fix: user roles * fix: half done * fix: thirdparty changes * fix: passwordless changes * fix: active users * fix: session changes * fix: user metadata * fix: user roles * fix: totp * fix: email verification * fix: multitenancy and other minor fixes * fix: compile errors * fix: bugs and tests * fix: bugs and tests * fix: func rename * fix: PR comments * fix: pr comments * fix: pr comments * fix: pr comments * fix: user role multitenant tests * fix: email verification tests * fix: user role deletion * fix: user roles * fix: user roles * fix: get tenant identifier refactor * fix: pr comments * fix: query * fix: tests version and changelog * Update CHANGELOG.md Co-authored-by: Rishabh Poddar <[email protected]> * fix: pr comments --------- Co-authored-by: Rishabh Poddar <[email protected]>
- Loading branch information
1 parent
b7fdaeb
commit d935c4e
Showing
150 changed files
with
3,490 additions
and
2,434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,45 @@ | ||
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(Main main, AppIdentifier appIdentifier, long time) | ||
throws StorageQueryException, TenantOrAppNotFoundException { | ||
return appIdentifierWithStorage.getActiveUsersStorage().countUsersActiveSince(appIdentifierWithStorage, time); | ||
Storage storage = StorageLayer.getStorage(appIdentifier.getAsPublicTenantIdentifier(), main); | ||
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); | ||
} | ||
|
||
public static void removeActiveUser(AppIdentifierWithStorage appIdentifierWithStorage, String userId) | ||
throws StorageQueryException { | ||
try { | ||
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).startTransaction(con -> { | ||
appIdentifierWithStorage.getActiveUsersStorage().deleteUserActive_Transaction(con, appIdentifierWithStorage, userId); | ||
((AuthRecipeSQLStorage) appIdentifierWithStorage.getActiveUsersStorage()).commitTransaction(con); | ||
return null; | ||
}); | ||
|
||
} catch (StorageTransactionLogicException e) { | ||
throw new StorageQueryException(e.actualException); | ||
} | ||
return countUsersActiveSince(main, new AppIdentifier(null, null), time); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/main/java/io/supertokens/TenantIdentifierWithStorageAndUserIdMapping.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.