X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=authserver%2Fauthd%2Fauthd.php;h=e0f7296b9a531b9cec0e65e0e827fd7090dfce0e;hp=67036a7ec754139e35d35627bd109ba99e5e494f;hb=d4590a3f34021216c9da29786922fddaf804d113;hpb=1438f7f5c47f3f5c55bc8e13aa566530840e0310 diff --git a/authserver/authd/authd.php b/authserver/authd/authd.php index 67036a7..e0f7296 100644 --- a/authserver/authd/authd.php +++ b/authserver/authd/authd.php @@ -36,6 +36,26 @@ if($pid == -1) { while(true) { msg_receive($sr_queue, 0, $msg_type, 16384, $msg); switch($msg_type) { + case MSG_DELETE_USER_TOKEN: + $username = $msg["username"]; + + $sql = "select users_otk from users where users_username='$username'"; + $dbo = getDatabase(); + $res = $dbo->query($sql); + $otkid = ""; + foreach($res as $row) { + $otkid = $row["users_otk"]; + } + if($otkid!="") { + unlink("otks/$otkid.png"); + } + + $sql = "update users set users_tokendata='',users_otk='' where users_username='$username'"; + $dbo = getDatabase(); + $res = $dbo->query($sql); + + msg_send($cl_queue, MSG_DELETE_USER_TOKEN, true); + break; case MSG_AUTH_USER_TOKEN: echo "Call to auth user token\n"; // minimal checking, we leav it up to authenticateUser to do the real @@ -89,9 +109,9 @@ if($pid == -1) { $hand = fopen("otks/$otk.png", "rb"); $data = fread($hand, filesize("otks/$otk.png")); fclose($hand); - //unlink("otks/$otk.png"); - //$sql = "update users set users_otk='' where users_username='$username'"; - //$dbo->query($sql); + unlink("otks/$otk.png"); + $sql = "update users set users_otk='' where users_username='$username'"; + $dbo->query($sql); error_log("senting otk, fsize: ".filesize("otks/$otk.png")." $otk "); msg_send($cl_queue, MSG_GET_OTK_PNG, $data); } @@ -106,7 +126,7 @@ if($pid == -1) { $username = $msg["username"]; $tokentype="HOTP"; if(isset($msg["tokentype"])) { - $tokentype="HOTP"; + $tokentype=$msg["tokentype"]; } $hexkey = ""; if(isset($msg["hexkey"])) { @@ -134,6 +154,19 @@ if($pid == -1) { } else { $username = $msg["username"]; global $myga; + + $sql = "select users_otk from users where users_username='$username'"; + $dbo = getDatabase(); + $res = $dbo->query($sql); + $otkid = ""; + foreach($res as $row) { + $otkid = $row["users_otk"]; + } + if($otkid!="") { + unlink("otks/$otkid.png"); + } + + $sql = "delete from users where users_username='$username'"; $dbo = getDatabase(); $dbo->query($sql);