Database access optimization if there is no shadow logins

This commit is contained in:
Grégory Soutadé 2017-04-17 20:37:26 +02:00
parent 6d2e202aff
commit 241867e93c

View File

@ -215,28 +215,29 @@ function delete_entry($user, $login, $access_token)
return false; return false;
} }
$db_ac = $db->querySingle("SELECT access_token FROM gpass WHERE login='" . $login . "'"); if ($USE_SHADOW_LOGINS)
if (strlen($db_ac) != 0 && strcmp($db_ac, $access_token))
{ {
$db->close(); $db_ac = $db->querySingle("SELECT access_token FROM gpass WHERE login='" . $login . "'");
echo "Bad access token"; if (strlen($db_ac) != 0 && strcmp($db_ac, $access_token))
{
$db->close();
echo "Bad access token";
return false;
}
}
$result = $db->query("DELETE FROM gpass WHERE login='" . $login . "'");
$db->close();
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false; return false;
} }
else else
{ {
$result = $db->query("DELETE FROM gpass WHERE login='" . $login . "'"); echo "OK";
$db->close(); return true;
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
} }
} }