File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 33 * Supports both /m licenses and /list commands
44 */
55
6+ const { getLinkedUser } = require ( '../client/DashboardClient' ) ;
7+
68module . 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` +
You can’t perform that action at this time.
0 commit comments