<?php
$locale->setSection("Admin: API");
$clientId = $str->fromHTML($_POST['id']);

if (!$users->userPerms->isSuperUser()) {
	jsonFeedback(false, "You are not allowed to access this page.");
}
$clients = new FileRun\OAuth2\ClientManager;
$clientInfo = $clients->getInfo($clientId);

if (!$clientInfo) {
	jsonFeedback(false, "Client not found!");
}

if ($config['misc']['demoMode']) {
	jsonFeedback(false, "Action unavailable in this demo version of the software!");
} else {
	$rs = $clients->deleteClient($clientId);
	if ($rs) {
		jsonFeedback(true, 'Oauth2 client successfully deleted');
	} else {
		jsonFeedback(false, "Failed to delete client!".$db->ErrorMsg());
	}
}
