Managing tokens with multiple site administrators

Re: Managing tokens with multiple site administrators

by Ray Hernandez -
Number of replies: 0

I totally agree with this. I don't understand why an admin can only see the tokens they've created. In lib/adminlib.php there is a DB query to pull the tokens for this page:

$sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.iprestriction, t.validuntil, s.id AS serviceid
FROM {external_tokens} t, {user} u, {external_services} s
WHERE t.creatorid=? AND t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id";
$tokens = $DB->get_records_sql($sql, array($USER->id, EXTERNAL_TOKEN_PERMANENT));

You can change it:

$sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.iprestriction, t.validuntil, s.id AS serviceid
FROM {external_tokens} t, {user} u, {external_services} s
WHERE t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id";
$tokens = $DB->get_records_sql($sql, array(EXTERNAL_TOKEN_PERMANENT));

This will allow an admin to see all the web tokens. Not sure why it isn't like this by default.