Skip to content

Commit 5f1ecf0

Browse files
committed
fix: SAML client count
1 parent 34d52a8 commit 5f1ecf0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/main/java/io/supertokens/storage/postgresql/Start.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,4 +4538,13 @@ public void removeExpiredSAMLCodesAndRelayStates() throws StorageQueryException
45384538
throw new StorageQueryException(e);
45394539
}
45404540
}
4541+
4542+
@Override
4543+
public int countSAMLClients(TenantIdentifier tenantIdentifier) throws StorageQueryException {
4544+
try {
4545+
return SAMLQueries.countSAMLClients(this, tenantIdentifier);
4546+
} catch (SQLException e) {
4547+
throw new StorageQueryException(e);
4548+
}
4549+
}
45414550
}

src/main/java/io/supertokens/storage/postgresql/queries/SAMLQueries.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,18 @@ public static void removeExpiredSAMLCodesAndRelayStates(Start start) throws Stor
407407
pst.setLong(1, expiredBefore);
408408
});
409409
}
410+
411+
public static int countSAMLClients(Start start, TenantIdentifier tenantIdentifier) throws StorageQueryException, SQLException {
412+
String QUERY = "SELECT COUNT(*) as c FROM " + getConfig(start).getSAMLClientsTable()
413+
+ " WHERE app_id = ? AND tenant_id = ?";
414+
return execute(start, QUERY, pst -> {
415+
pst.setString(1, tenantIdentifier.getAppId());
416+
pst.setString(2, tenantIdentifier.getTenantId());
417+
}, result -> {
418+
if (result.next()) {
419+
return result.getInt("c");
420+
}
421+
return 0;
422+
});
423+
}
410424
}

0 commit comments

Comments
 (0)