fix: BUG-046 usage endpoint data leak, BUG-047 copy button, BUG-048 email change links
All checks were successful
Deploy to Production / Deploy to Server (push) Successful in 1m18s
All checks were successful
Deploy to Production / Deploy to Server (push) Successful in 1m18s
BUG-046 (CRITICAL): getUsageStats() now accepts apiKey param and returns only that key usage instead of all users. Route passes req.apiKeyInfo.key. BUG-047: Added visible Copy button to Pro key success page in billing.ts. BUG-048: Added class="open-email-change" to Change Email links in all HTML pages so the JS modal opener can find them.
This commit is contained in:
parent
a1d26b85ec
commit
b98e8bc253
10 changed files with 24 additions and 18 deletions
11
dist/middleware/usage.js
vendored
11
dist/middleware/usage.js
vendored
|
|
@ -65,11 +65,14 @@ function trackUsage(key, monthKey) {
|
|||
saveUsageEntry(key, record).catch((err) => logger.error({ err }, "Failed to save usage entry"));
|
||||
}
|
||||
}
|
||||
export function getUsageStats() {
|
||||
export function getUsageStats(apiKey) {
|
||||
const stats = {};
|
||||
for (const [key, record] of usage) {
|
||||
const masked = key.slice(0, 8) + "...";
|
||||
stats[masked] = { count: record.count, month: record.monthKey };
|
||||
if (apiKey) {
|
||||
const record = usage.get(apiKey);
|
||||
if (record) {
|
||||
const masked = apiKey.slice(0, 8) + "...";
|
||||
stats[masked] = { count: record.count, month: record.monthKey };
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue