Browse files

MDL-29931 remove unneeded join and selects

  • Loading branch information...
1 parent 0d7773c commit fae4f8f1b916acb755a1f7754c3cc23ad5d95e40 @mouneyrac mouneyrac committed Oct 31, 2011
Showing with 3 additions and 8 deletions.
  1. +3 −8 login/token.php
View
11 login/token.php
@@ -92,16 +92,11 @@
//Check if a token has already been created for this user and this service
//Note: this could be an admin created or an user created token.
// It does not really matter we take the first one that is valid.
- $tokenssql = "SELECT t.id, t.sid, t.token, t.validuntil, t.iprestriction,
- s.restrictedusers, s.id as serviceid, s.requiredcapability
+ $tokenssql = "SELECT t.id, t.sid, t.token, t.validuntil, t.iprestriction
FROM {external_tokens} t
- JOIN {external_services} s
- ON t.externalserviceid = s.id
- WHERE s.shortname = ?
- AND s.enabled = 1
- AND t.userid = ?
+ WHERE t.userid = ? AND t.externalserviceid = ?
ORDER BY t.timecreated ASC";
- $tokens = $DB->get_records_sql($tokenssql, array($serviceshortname, $user->id, time()));
+ $tokens = $DB->get_records_sql($tokenssql, array($user->id, $service->id));
//A bit of sanity checks
foreach ($tokens as $key=>$token) {

0 comments on commit fae4f8f

Please sign in to comment.