feat: detect duplicates in csv
This commit is contained in:
@@ -32,8 +32,17 @@ function handle_get(): never
|
||||
FROM delivery_log"
|
||||
)->fetch();
|
||||
|
||||
$groups_raw = $_SERVER['HTTP_X_AUTHENTIK_GROUPS'] ?? '';
|
||||
$groups = ($groups_raw !== '') ? explode('|', $groups_raw) : [];
|
||||
$is_admin = in_array('imf_sms_admin', $groups, true);
|
||||
$username = $_SERVER['HTTP_X_AUTHENTIK_USERNAME'] ?? '';
|
||||
$name = $_SERVER['HTTP_X_AUTHENTIK_NAME'] ?? $username;
|
||||
|
||||
json_out([
|
||||
'sandbox_mode' => $sandbox_mode,
|
||||
'is_admin' => $is_admin,
|
||||
'username' => $username,
|
||||
'name' => $name,
|
||||
'delivery_log_total' => (int) ($counts['total'] ?? 0),
|
||||
'delivery_log_sandbox' => (int) ($counts['sandbox_count'] ?? 0),
|
||||
'delivery_log_real_sent' => (int) ($counts['real_sent'] ?? 0),
|
||||
@@ -44,10 +53,23 @@ function handle_get(): never
|
||||
]);
|
||||
}
|
||||
|
||||
// ─── Admin guard ─────────────────────────────────────────────────────────────
|
||||
|
||||
function require_admin(): void
|
||||
{
|
||||
$groups_raw = $_SERVER['HTTP_X_AUTHENTIK_GROUPS'] ?? '';
|
||||
$groups = ($groups_raw !== '') ? explode('|', $groups_raw) : [];
|
||||
if (!in_array('imf_sms_admin', $groups, true)) {
|
||||
error_out('Forbidden — requires imf_sms_admin group', 403);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── POST /api/admin.php ──────────────────────────────────────────────────────
|
||||
|
||||
function handle_post(): never
|
||||
{
|
||||
require_admin();
|
||||
|
||||
$body = json_body();
|
||||
$action = (string) ($body['action'] ?? '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user