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;
}
$db_ac = $db->querySingle("SELECT access_token FROM gpass WHERE login='" . $login . "'");
if (strlen($db_ac) != 0 && strcmp($db_ac, $access_token))
if ($USE_SHADOW_LOGINS)
{
$db->close();
echo "Bad access token";
$db_ac = $db->querySingle("SELECT access_token FROM gpass WHERE login='" . $login . "'");
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;
}
else
{
$result = $db->query("DELETE FROM gpass WHERE login='" . $login . "'");
$db->close();
if ($result == FALSE)
{
echo "Error " . $db->lastErrorMsg();
return false;
}
else
{
echo "OK";
return true;
}
echo "OK";
return true;
}
}