Skip to content

Commit

Permalink
Only revoke voucher on guest auth success
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlgo11 committed Feb 13, 2021
1 parent e8d6f64 commit a42f5b0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions php/submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@
if (isset($voucher['qos_usage_quota'])) $usage_quota = $voucher['qos_usage_quota'];

$authorized = $unifi_connection->authorize_guest($mac, $voucher['duration'], $max_up, $max_down, $usage_quota, $ap_mac);
$unifi_connection->revoke_voucher($voucher['_id']);
header('Status: 202');
print(json_encode(['success' => TRUE], JSON_PRETTY_PRINT));
if ($authorized) {
header('Status: 202');
$unifi_connection->revoke_voucher($voucher['_id']);
}
else header('Status: 500');
print(json_encode(['success' => $authorized]));
return;
}
}
Expand Down

0 comments on commit a42f5b0

Please sign in to comment.