echo "Call to auth user token\n";
// minimal checking, we leav it up to authenticateUser to do the real
// checking
- if(!isset($msg["user"])) $msg["user"] = "";
+ if(!isset($msg["username"])) $msg["username"] = "";
if(!isset($msg["passcode"])) $msg["passcode"] = "";
- $username = $msg["user"];
+ $username = $msg["username"];
$passcode = $msg["passcode"];
global $myga;
- msg_send($cl_queue, MSG_AUTH_USER_TOKEN, $myga->authenticateUser($username, $passcode));
+ $authval = $myga->authenticateUser($username, $passcode);
+ msg_send($cl_queue, MSG_AUTH_USER_TOKEN, $authval);
break;
case MSG_ADD_USER_TOKEN:
echo "Call to add user token\n";
if(!isset($msg["username"])) {
msg_send($cl_queue, MSG_ADD_USER_TOKEN, false);
} else {
- $username = $msg["username"];
+ $username = $msg["username"];
+ $tokentype="HOTP";
+ if(isset($msg["tokentype"])) {
+ $tokentype="HOTP";
+ }
+ $hexkey = "";
+ if(isset($msg["hexkey"])) {
+ $hexkey = $msg["hexkey"];
+ }
global $myga;
- msg_send($cl_queue, MSG_ADD_USER_TOKEN, $myga->setUser($username));
+ $myga->setUser($username, $tokentype, "", $hexkey);
+
+ msg_send($cl_queue, MSG_ADD_USER_TOKEN, $myga->createUrl($username));
}
break;
case MSG_DELETE_USER:
global $myga;
msg_send($cl_queue, MSG_DELETE_USER, $myga->deleteUser($username));
}
+ break;
case MSG_AUTH_USER_PASSWORD:
// TODO
echo "Call to auth user pass\n";
$username = $msg["username"];
$realname = $msg["realname"];
$sql = "update users set users_realname='$realname' where users_username='$username'";
- echo "sql: $sql\n";
$dbo = getDatabase();
$dbo->query($sql);
}
global $myga;
- msg_send($cl_queue, MSG_SET_USER_TOKEN, $myga->setUserKey($username, $passcode));
+ $myga->setUserKey($username, $passcode);
+ msg_send($cl_queue, MSG_SET_USER_TOKEN, $myga->createUrl($username));
// TODO now set token
break;
msg_send($cl_queue, MSG_SET_USER_TOKEN_TYPE, $myga->setTokenType($username, $tokentype));
// TODO now set token
- break;
+ break;
+ case MSG_GET_USERS:
+ // TODO this needs to be better
+ $sql = "select * from users";
+
+ $dbo = getDatabase();
+ $res = $dbo->query($sql);
+
+ $users = "";
+ $i = 0;
+ foreach($res as $row) {
+ $users[$i]["username"] = $row["users_username"];
+ $users[$i]["realname"] = $row["users_realname"];
+ if($row["users_password"]!="") {
+ $users[$i]["haspass"] = true;
+ } else {
+ $users[$i]["haspass"] = false;
+ }
+ echo "user: ".$users[$i]["username"]." has tdata: \"".$row["users_tokendata"]."\"\n";
+ if($row["users_tokendata"]!="") {
+ $users[$i]["hastoken"] = true;
+ } else {
+ $users[$i]["hastoken"] = false;
+ }
+ $i++;
+ }
+ msg_send($cl_queue, MSG_GET_USERS, $users);
+
+ // TODO now set token
+ break;
}
}
}
-?>
\ No newline at end of file
+?>