Passwort reset

This commit is contained in:
2023-02-09 11:11:53 +01:00
parent 0c5cfcbd19
commit 2a02c79370
5 changed files with 186 additions and 13 deletions

View File

@ -119,6 +119,34 @@ function getNewFilename($targetDir, $fileExt, $length)
return $newFname .".".$fileExt;
}
function getNewPwtoken($length, $conn)
{
$newToken = random_str($length);
$maxtries = 100000; // prevent endless loop, most unlikely
$tries = 0;
do
{
$stmt = $conn->prepare("SELECT id FROM `dogs` WHERE `pwtoken`=?");
$stmt->execute([$newToken]);
if ($stmt->rowCount() == 0)
{
break;
}
$newToken = random_str($length);
echo ('newToken ' . $newToken);
++$tries;
} while ($tries <= $maxtries);
if($tries >= $maxtries)
{
$newToken = "";
}
return $newToken;
}
function getDogByQrId($qr_id, $conn, $fields = null)
{
if(strcmp($qr_id, 'SESS') === 0)