mirror of
https://github.com/getnamingo/registry.git
synced 2025-06-29 07:33:27 +02:00
Domain update improvements, dnssec records can be deleted now
This commit is contained in:
parent
be28985948
commit
9a45cdab9e
4 changed files with 121 additions and 13 deletions
|
@ -1433,6 +1433,54 @@ class DomainsController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function domainDeleteSecdns(Request $request, Response $response)
|
||||||
|
{
|
||||||
|
$db = $this->container->get('db');
|
||||||
|
$data = $request->getParsedBody();
|
||||||
|
$uri = $request->getUri()->getPath();
|
||||||
|
|
||||||
|
if ($data['record']) {
|
||||||
|
$record = filter_var($data['record'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
$domain_id = filter_var($data['domain_id'], FILTER_SANITIZE_NUMBER_INT);
|
||||||
|
|
||||||
|
$domainName = $db->selectValue('SELECT name FROM domain WHERE id = ?',
|
||||||
|
[ $domain_id ]);
|
||||||
|
$db->delete(
|
||||||
|
'secdns',
|
||||||
|
[
|
||||||
|
'id' => $record,
|
||||||
|
'domain_id' => $domain_id
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->container->get('flash')->addMessage('success', 'Record has been removed from domain successfully');
|
||||||
|
|
||||||
|
$jsonData = json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'redirect' => '/domain/update/'.$domainName
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = new \Nyholm\Psr7\Response(
|
||||||
|
200, // Status code
|
||||||
|
['Content-Type' => 'application/json'], // Headers
|
||||||
|
$jsonData // Body
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
} else {
|
||||||
|
$jsonData = json_encode([
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'An error occurred while processing your request.'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return new \Nyholm\Psr7\Response(
|
||||||
|
400,
|
||||||
|
['Content-Type' => 'application/json'],
|
||||||
|
$jsonData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function renewDomain(Request $request, Response $response, $args)
|
public function renewDomain(Request $request, Response $response, $args)
|
||||||
{
|
{
|
||||||
if ($request->getMethod() === 'POST') {
|
if ($request->getMethod() === 'POST') {
|
||||||
|
|
|
@ -213,6 +213,9 @@ $csrfMiddleware = function ($request, $handler) use ($container) {
|
||||||
if ($path && $path === '/domain/deletehost') {
|
if ($path && $path === '/domain/deletehost') {
|
||||||
return $handler->handle($request);
|
return $handler->handle($request);
|
||||||
}
|
}
|
||||||
|
if ($path && $path === '/domain/deletesecdns') {
|
||||||
|
return $handler->handle($request);
|
||||||
|
}
|
||||||
|
|
||||||
// If not skipped, apply the CSRF Guard
|
// If not skipped, apply the CSRF Guard
|
||||||
return $csrf->process($request, $handler);
|
return $csrf->process($request, $handler);
|
||||||
|
|
|
@ -126,22 +126,55 @@
|
||||||
<label for="authInfo" class="form-label">{{ __('DNSSEC Data') }}</label>
|
<label for="authInfo" class="form-label">{{ __('DNSSEC Data') }}</label>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-vcenter card-table table-striped">
|
<table class="table table-vcenter card-table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
{% set dsDataExists = false %}
|
||||||
|
{% set keyDataExists = false %}
|
||||||
|
|
||||||
|
{% for row in domainSecdns %}
|
||||||
|
{% if row.interface == 'dsData' %}
|
||||||
|
{% set dsDataExists = true %}
|
||||||
|
{% elseif row.interface == 'keyData' %}
|
||||||
|
{% set keyDataExists = true %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<!-- Headers for dsData -->
|
||||||
|
{% if dsDataExists %}
|
||||||
|
<th>Keytag</th>
|
||||||
|
<th>Algorithm</th>
|
||||||
|
<th>Digest Type</th>
|
||||||
|
<th>Digest</th>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Headers for keyData -->
|
||||||
|
{% if keyDataExists %}
|
||||||
|
<th>Flags</th>
|
||||||
|
<th>Protocol</th>
|
||||||
|
<th>Keydata Algorithm</th>
|
||||||
|
<th>Public Key</th>
|
||||||
|
{% endif %}
|
||||||
|
<th> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for row in domainSecdns %}
|
{% for row in domainSecdns %}
|
||||||
<tr>
|
<tr>
|
||||||
{% for key, value in row %}
|
{% if row.interface == 'dsData' %}
|
||||||
{% if key not in ['id', 'domain_id', 'maxsiglife'] %}
|
<td>{{ row.keytag }}</td>
|
||||||
<th>{{ key }}</th>
|
<td>{{ row.alg }}</td>
|
||||||
|
<td>{{ row.digesttype }}</td>
|
||||||
|
<td>{{ row.digest }}</td>
|
||||||
|
{% elseif row.interface == 'keyData' %}
|
||||||
|
<td>{{ row.flags }}</td>
|
||||||
|
<td>{{ row.protocol }}</td>
|
||||||
|
<td>{{ row.keydata_alg }}</td>
|
||||||
|
<td>{{ row.pubkey }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
<td><button type="button" class="btn btn-dark btn-icon" onclick="sendSecRequest('{{ row.id }}','{{ row.domain_id }}')" title="Delete record"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 10l4 4m0 -4l-4 4" /><path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z" /></svg></button></td>
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
{% for key, value in row %}
|
|
||||||
{% if key not in ['id', 'domain_id', 'maxsiglife'] %}
|
|
||||||
<td>{{ value }}</td>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -253,6 +286,29 @@ function sendRequest(nameserver) {
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendSecRequest(record,domain_id) {
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('record', record);
|
||||||
|
formData.append('domain_id', domain_id);
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('POST', '/domain/deletesecdns');
|
||||||
|
xhr.onreadystatechange = function() {
|
||||||
|
if (xhr.readyState == 4) {
|
||||||
|
var response = JSON.parse(xhr.responseText);
|
||||||
|
if (xhr.status == 200 && response.success) {
|
||||||
|
// Redirect to the provided URL
|
||||||
|
window.location.href = response.redirect;
|
||||||
|
} else {
|
||||||
|
// Handle error
|
||||||
|
console.error('Error: ' + response.error);
|
||||||
|
alert('Error: ' + response.error); // Display error message to the user
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(formData);
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
|
||||||
const addNameserverBtn = document.getElementById('addNameserver');
|
const addNameserverBtn = document.getElementById('addNameserver');
|
||||||
|
|
|
@ -44,6 +44,7 @@ $app->group('', function ($route) {
|
||||||
$route->get('/domain/view/{domain}', DomainsController::class . ':viewDomain')->setName('viewDomain');
|
$route->get('/domain/view/{domain}', DomainsController::class . ':viewDomain')->setName('viewDomain');
|
||||||
$route->get('/domain/update/{domain}', DomainsController::class . ':updateDomain')->setName('updateDomain');
|
$route->get('/domain/update/{domain}', DomainsController::class . ':updateDomain')->setName('updateDomain');
|
||||||
$route->post('/domain/update', DomainsController::class . ':updateDomainProcess')->setName('updateDomainProcess');
|
$route->post('/domain/update', DomainsController::class . ':updateDomainProcess')->setName('updateDomainProcess');
|
||||||
|
$route->post('/domain/deletesecdns', DomainsController::class . ':domainDeleteSecdns')->setName('domainDeleteSecdns');
|
||||||
$route->post('/domain/deletehost', DomainsController::class . ':domainDeleteHost')->setName('domainDeleteHost');
|
$route->post('/domain/deletehost', DomainsController::class . ':domainDeleteHost')->setName('domainDeleteHost');
|
||||||
$route->map(['GET', 'POST'], '/domain/renew/{domain}', DomainsController::class . ':renewDomain')->setName('renewDomain');
|
$route->map(['GET', 'POST'], '/domain/renew/{domain}', DomainsController::class . ':renewDomain')->setName('renewDomain');
|
||||||
$route->map(['GET', 'POST'], '/domain/delete/{domain}', DomainsController::class . ':deleteDomain')->setName('deleteDomain');
|
$route->map(['GET', 'POST'], '/domain/delete/{domain}', DomainsController::class . ':deleteDomain')->setName('deleteDomain');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue