change to user_list to fetch from radusergroup / groupname

This commit is contained in:
2025-03-28 16:27:53 -04:00
parent 396fd2f3b4
commit 2d0247d0d9
2 changed files with 51 additions and 32 deletions

View File

@@ -96,12 +96,12 @@ def user_list():
cursor.execute("""
SELECT
rc.username AS mac_address,
IFNULL((SELECT value FROM radgroupreply rgr
WHERE rgr.groupname = (SELECT groupname FROM radusergroup rug WHERE rug.username = rc.username LIMIT 1)
AND rgr.attribute = 'Tunnel-Private-Group-Id' LIMIT 1), 'N/A') AS vlan_id,
IFNULL(rug.groupname, 'N/A') AS vlan_id, -- Changed to get groupname from radusergroup
IFNULL((SELECT value FROM radcheck rch
WHERE rch.username = rc.username AND rch.attribute = 'User-Description' LIMIT 1), 'N/A') AS description
FROM radcheck rc
LEFT JOIN radusergroup rug ON rc.username = rug.username -- Join radcheck and radusergroup
WHERE rc.attribute = 'Cleartext-Password'
GROUP BY rc.username;
""")
results = cursor.fetchall()