Skip to content

Commit

Permalink
Merge branch 'multi-tenant-config' into feat/mfa
Browse files Browse the repository at this point in the history
  • Loading branch information
KShivendu authored May 26, 2023
2 parents 7ca0f44 + 3e37980 commit 9f3b681
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

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(AppIdentifier appIdentifier, String userId) throws StorageQueryException;

Expand All @@ -21,4 +22,7 @@ public interface ActiveUsersStorage extends Storage {

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

/* Delete a user from active users table */
void deleteUserActive(AppIdentifier appIdentifier, String userId) throws StorageQueryException;
}
2 changes: 2 additions & 0 deletions src/main/java/io/supertokens/pluginInterface/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ boolean isUserIdBeingUsedInNonAuthRecipe(AppIdentifier appIdentifier, String cla
String[] getProtectedConfigsFromSuperTokensSaaSUsers();

Set<String> getValidFieldsInConfig();

void setLogLevels(Set<LOG_LEVEL> logLevels);
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public TenantConfig(@Nonnull TenantIdentifier tenantIdentifier, @Nonnull EmailPa
this.thirdPartyConfig = thirdPartyConfig;
}

public TenantConfig(TenantConfig other) {
// copy constructor, that does a deep copy
Gson gson = new Gson();
this.tenantIdentifier = new TenantIdentifier(other.tenantIdentifier.getConnectionUriDomain(), other.tenantIdentifier.getAppId(), other.tenantIdentifier.getTenantId());
this.coreConfig = gson.fromJson(other.coreConfig.toString(), JsonObject.class);
this.emailPasswordConfig = new EmailPasswordConfig(other.emailPasswordConfig.enabled);
this.passwordlessConfig = new PasswordlessConfig(other.passwordlessConfig.enabled);
this.thirdPartyConfig = gson.fromJson(gson.toJsonTree(other.thirdPartyConfig).getAsJsonObject(), ThirdPartyConfig.class);
}

public boolean deepEquals(TenantConfig other) {
if (other == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ public boolean equals(Object other) {
}

public static class UserInfoMapKeyValue {
@Nonnull
@Nullable
public String userId;

@Nonnull
@Nullable
public String email;

@Nonnull
@Nullable
public String emailVerified;

public UserInfoMapKeyValue(@Nonnull String userId, @Nonnull String email, @Nonnull String emailVerified) {
public UserInfoMapKeyValue(@Nullable String userId, @Nullable String email, @Nullable String emailVerified) {
this.userId = userId;
this.email = email;
this.emailVerified = emailVerified;
Expand All @@ -217,9 +217,9 @@ public UserInfoMapKeyValue(@Nonnull String userId, @Nonnull String email, @Nonnu
public boolean equals(Object other) {
if (other instanceof UserInfoMapKeyValue) {
UserInfoMapKeyValue otherUserInfoMapKeyValue = (UserInfoMapKeyValue) other;
return otherUserInfoMapKeyValue.userId.equals(this.userId) &&
otherUserInfoMapKeyValue.email.equals(this.email) &&
otherUserInfoMapKeyValue.emailVerified.equals(this.emailVerified);
return Objects.equals(otherUserInfoMapKeyValue.userId, this.userId) &&
Objects.equals(otherUserInfoMapKeyValue.email, this.email) &&
Objects.equals(otherUserInfoMapKeyValue.emailVerified, this.emailVerified);
}
return false;
}
Expand Down

0 comments on commit 9f3b681

Please sign in to comment.