Skip to content

Commit abda1de

Browse files
committed
fix(tg-bot): filter /list to current user (no app-wide leak)
1 parent 3444fd9 commit abda1de

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/commands/list.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Supports both /m licenses and /list commands
44
*/
55

6+
const { getLinkedUser } = require('../client/DashboardClient');
7+
68
module.exports = {
79
name: 'list',
810
description: 'List user licenses',
@@ -66,6 +68,22 @@ module.exports = {
6668
}
6769
}
6870

71+
// Prevent app-wide license leakage: scope to the caller via Dashboard-linked email.
72+
// If the user is not linked (or email missing), show an empty list.
73+
const linked = await getLinkedUser(userId, { platform: 'telegram' });
74+
const linkedEmail = (linked && linked.email ? String(linked.email) : '').trim().toLowerCase();
75+
if (!linkedEmail) {
76+
licenses = [];
77+
} else {
78+
licenses = licenses.filter((license) => {
79+
const issuedEmail = (license?.issuedEmail ? String(license.issuedEmail) : '')
80+
.trim()
81+
.toLowerCase();
82+
const email = (license?.email ? String(license.email) : '').trim().toLowerCase();
83+
return issuedEmail === linkedEmail || email === linkedEmail;
84+
});
85+
}
86+
6987
if (licenses.length === 0) {
7088
await bot.editMessageText(
7189
`📋 *Your Licenses*\n\n` +

0 commit comments

Comments
 (0)