Skip to content

Commit

Permalink
fix: pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Sep 19, 2024
1 parent 87fc19f commit eb3a1dc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/supertokens/storage/postgresql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -3141,10 +3141,10 @@ public void revoke(AppIdentifier appIdentifier, String targetType, String target
}

@Override
public boolean isRevoked(AppIdentifier appIdentifier, String targetType, String targetValue, long issuedAt)
public boolean isRevoked(AppIdentifier appIdentifier, String[] targetTypes, String[] targetValues, long issuedAt)
throws StorageQueryException {
try {
return OAuthQueries.isRevoked(this, appIdentifier, targetType, targetValue, issuedAt);
return OAuthQueries.isRevoked(this, appIdentifier, targetTypes, targetValues, issuedAt);
} catch (SQLException e) {
throw new StorageQueryException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,32 @@ public static void revoke(Start start, AppIdentifier appIdentifier, String targe
});
}

public static boolean isRevoked(Start start, AppIdentifier appIdentifier, String targetType, String targetValue, long issuedAt)
public static boolean isRevoked(Start start, AppIdentifier appIdentifier, String[] targetTypes, String[] targetValues, long issuedAt)
throws SQLException, StorageQueryException {
String QUERY = "SELECT app_id FROM " + Config.getConfig(start).getOAuthRevokeTable() +
" WHERE app_id = ? AND target_type = ? AND target_value = ? and timestamp > ?";
" WHERE app_id = ? AND timestamp > ? AND (";

for (int i = 0; i < targetTypes.length; i++) {
QUERY += "(target_type = ? AND target_value = ?)";

if (i < targetTypes.length - 1) {
QUERY += " OR ";
}
}

QUERY += ")";

return execute(start, QUERY, pst -> {
pst.setString(1, appIdentifier.getAppId());
pst.setString(2, targetType);
pst.setString(3, targetValue);
pst.setLong(4, issuedAt);
pst.setLong(2, issuedAt);

int index = 3;
for (int i = 0; i < targetTypes.length; i++) {
pst.setString(index, targetTypes[i]);
index++;
pst.setString(index, targetValues[i]);
index++;
}
}, ResultSet::next);
}
}

0 comments on commit eb3a1dc

Please sign in to comment.