Cursory wsapi v2.0 support (backwards compatible)
authorDan Fuhry <dan@enanocms.org>
Fri, 08 Apr 2016 17:23:16 -0400
changeset 10 351d40b21cbc
parent 9 d58bafde2a92
child 11 b9eb748ac1e4
Cursory wsapi v2.0 support (backwards compatible)
yms/validate-functions.php
yms/validate.php
--- a/yms/validate-functions.php	Fri Apr 08 17:22:15 2016 -0400
+++ b/yms/validate-functions.php	Fri Apr 08 17:23:16 2016 -0400
@@ -27,6 +27,10 @@
   $result = "h={$hash}\n";
   foreach ( $response as $key => $value )
   {
+    if ( $value === null )
+    {
+      continue;
+    }
     $result .= "{$key}={$value}\n";
   }
   return trim($result);
--- a/yms/validate.php	Fri Apr 08 17:22:15 2016 -0400
+++ b/yms/validate.php	Fri Apr 08 17:23:16 2016 -0400
@@ -16,6 +16,12 @@
   {
     yms_send_reply('MISSING_PARAMETER', '', array('info' => 'otp'));
   }
+
+  $nonce = null;
+  if ( isset($_GET['nonce']) )
+  {
+    $nonce = $_GET['nonce'];
+  }
   
   // first, get API key so we can properly sign responses
   $id = intval($_GET['id']);
@@ -42,6 +48,6 @@
   
   $GLOBALS['g_api_key'] =& $g_api_key;
   
-  yms_send_reply(yms_validate_otp($_GET['otp'], $id));
+  yms_send_reply(yms_validate_otp($_GET['otp'], $id), '', array('nonce' => $nonce, 'otp' => $_GET['otp']));
 }