<?php

use MintyPHP\Http\Request;
use MintyPHP\Router;
use MintyPHP\Support\Flash;

$request = requestInput();
$target = Request::safeReturnTarget($request->bodyAll()['return'] ?? '');

if (!actionRequirePost($target)) {
    return;
}

if (!actionRequireCsrf($target, flashOnFailure: false)) {
    return;
}

$flashId = isset($id) ? trim((string) $id) : '';
if ($flashId !== '') {
    Flash::dismiss($flashId);
}
Router::redirect($target);
