Require token for wash certificate downloads
This commit is contained in:
@@ -20,7 +20,11 @@ if (!is_numeric($certificate_id) || $certificate_id < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Add authentication here
|
||||
// Require a valid static token before serving certificates
|
||||
if (!isset($_GET['secret_token']) || $_GET['secret_token'] !== $WORDPRESS_STATIC_TOKEN) {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the certificate exists in the /output/certificates folder
|
||||
if (!file_exists("../output/certificates/wash_certificate_" . $certificate_id . ".pdf")) {
|
||||
@@ -34,4 +38,4 @@ header('Content-Disposition: attachment; filename="wash certificate ' . $certifi
|
||||
|
||||
// Output the certificate
|
||||
readfile("../output/certificates/wash_certificate_" . $certificate_id . ".pdf");
|
||||
exit;
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user