+ // Return whether something has been inserted or updated
+ return (sqlAffectedRows() == 1);
+}
+
+//-----------------------------------------------------------------------------
+// Auth status callback functions
+//-----------------------------------------------------------------------------
+
+// Handler for auth_status=PENDING
+function doWernisAuthPending ($args) {
+ // $args must always be an array
+ assert(is_array($args));
+
+ // auth_key and wernis_userid must be set
+ assert(isset($args['auth_key']));
+ assert(isset($args['wernis_userid']));
+
+ // Generate a challenge that will be added to the URL
+ $challenge = hashSha256(generatePassword(128));
+
+ // Register or update the record
+ $registered = registerUpdateWernisRegistrationCall($args, $challenge, 'PENDING');
+
+ // Should always register/update
+ assert($registered === TRUE);