fixed a minor thing with the hotp skew
[ga4php.git] / authserver / usercmd.php
index f6ff83c..289922a 100644 (file)
@@ -13,21 +13,63 @@ require_once("lib/authClient.php");
 
 $myAC = new GAAuthClient();
 
+/*
+define("MSG_AUTH_USER_TOKEN", 1);
+define("MSG_ADD_USER_TOKEN", 2);
+define("MSG_DELETE_USER", 3);
+define("MSG_AUTH_USER_PASSWORD", 4);
+define("MSG_SET_USER_PASSWORD", 5);
+define("MSG_SET_USER_REALNAME", 6);
+define("MSG_SET_USER_TOKEN", 7);
+define("MSG_SET_USER_TOKEN_TYPE", 8);
+
+ */
 if(!isset($argv[1])) {
-       echo "Usage: ".$argv[0]." add|auth username passcode\n";
+       echo "Usage: ".$argv[0]." command username [args]\n";
+       echo "\tadd: add <username> - returns token code url\n";
+       echo "\tauth: auth <username> <passcode> - returns 0/1 for pass/fail\n";
+       echo "\tdelete: delete <username> - deletes user\n";
+       echo "\tauthpass: authpass <username> <password> - returns 0/1 for pass/fail\n";
+       echo "\tsetpass: setpass <username> <password> - sets a password for a user (x to remove pass)\n";
+       echo "\tsetname: setname <username> <realname> - sets the real name for a user\n";
+       echo "\tsettoken: settoken <username> <tokenkey> - sets the key (hex) for a token\n";
+       echo "\tsettype: settype <username> <tokentype> - sets a token type for a user\n";
+       echo "\tgetusers: getusers - gets a list of users\n";
        return 0;       
 }
 
 switch($argv[1]) {
        case "auth":
-               if($myAC->authUser($argv[2], $argv[3])==1) {
+               if($myAC->authUserToken($argv[2], $argv[3])==1) {
                        echo "Pass!";
                } else {
                        echo "Fail!";
                }
                break;
        case "add":
-               $myAC->addUser($argv[2]);
+               $return = $myAC->addUser($argv[2]);
+               echo "Created user, ".$argv[2]." returned $return\n";
+               break;
+       case "delete":
+               $myAC->deleteUser($argv[2]);
+               break;
+       case "authpass":
+               $myAC->authUserPass($argv[2], $argv[3]);
+               break;
+       case "setpass":
+               $myAC->setUserPass($argv[2], $argv[3]);
+               break;
+       case "setname":
+               $myAC->setUserRealName($argv[2], $argv[3]);
+               break;
+       case "settoken":
+               $myAC->setUserToken($argv[2], $argv[3]);
+               break;
+       case "settype":
+               $myAC->setUserTokenType($argv[2], $argv[3]);
+               break;
+       case "getusers":
+               $myAC->getUsers();
                break;
 }
 ?>
\ No newline at end of file