Fixes for transfers and registrar creation

This commit is contained in:
Pinga 2023-12-07 12:44:04 +02:00
parent 195f54836a
commit 96034f2219
3 changed files with 37 additions and 22 deletions

View file

@ -1857,7 +1857,7 @@ class DomainsController extends Controller
$data = $request->getParsedBody(); $data = $request->getParsedBody();
$db = $this->container->get('db'); $db = $this->container->get('db');
$domainName = $data['domainName'] ?? null; $domainName = $data['domainName'] ?? null;
$registrar = $data['registrar'] ?? null; $registrar_id = $data['registrar'] ?? null;
$authInfo = $data['authInfo'] ?? null; $authInfo = $data['authInfo'] ?? null;
$transferYears = $data['transferYears'] ?? null; $transferYears = $data['transferYears'] ?? null;
@ -1883,7 +1883,7 @@ class DomainsController extends Controller
if ($_SESSION["auth_roles"] != 0) { if ($_SESSION["auth_roles"] != 0) {
$clid = $result['registrar_id']; $clid = $result['registrar_id'];
} else { } else {
$clid = $db->selectValue('SELECT clid FROM domain WHERE name = ?', [$domainName]); $clid = $registrar_id;
} }
$days_from_registration = $db->selectValue( $days_from_registration = $db->selectValue(
@ -1948,7 +1948,7 @@ class DomainsController extends Controller
} }
} }
if ($clid !== $registrar_id_domain) { if ($clid == $registrar_id_domain) {
$this->container->get('flash')->addMessage('error', 'Destination client of the transfer operation is the domain sponsoring client'); $this->container->get('flash')->addMessage('error', 'Destination client of the transfer operation is the domain sponsoring client');
return $response->withHeader('Location', '/transfer/request')->withStatus(302); return $response->withHeader('Location', '/transfer/request')->withStatus(302);
} }
@ -2135,13 +2135,10 @@ class DomainsController extends Controller
public function approveTransfer(Request $request, Response $response, $args) public function approveTransfer(Request $request, Response $response, $args)
{ {
if ($request->getMethod() === 'POST') { //if ($request->getMethod() === 'POST') {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
$db = $this->container->get('db'); $db = $this->container->get('db');
$domainName = $args ?? null; $domainName = $args ?? null;
$registrar = $data['registrar'] ?? null;
$authInfo = $data['authInfo'] ?? null;
$transferYears = $data['transferYears'] ?? null;
if (!$domainName) { if (!$domainName) {
$this->container->get('flash')->addMessage('error', 'Please provide the domain name'); $this->container->get('flash')->addMessage('error', 'Please provide the domain name');
@ -2155,6 +2152,14 @@ class DomainsController extends Controller
$tldid = $domain['tldid']; $tldid = $domain['tldid'];
$registrar_id_domain = $domain['clid']; $registrar_id_domain = $domain['clid'];
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
if ($_SESSION["auth_roles"] != 0) {
$clid = $result['registrar_id'];
} else {
$clid = $db->selectValue('SELECT clid FROM domain WHERE name = ?', [$domainName]);
}
$domain_authinfo_id = $db->selectValue( $domain_authinfo_id = $db->selectValue(
'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1', 'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1',
[ [
@ -2296,18 +2301,15 @@ class DomainsController extends Controller
$this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer'); $this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer');
return $response->withHeader('Location', '/transfers')->withStatus(302); return $response->withHeader('Location', '/transfers')->withStatus(302);
} }
} //}
} }
public function rejectTransfer(Request $request, Response $response, $args) public function rejectTransfer(Request $request, Response $response, $args)
{ {
if ($request->getMethod() === 'POST') { //if ($request->getMethod() === 'POST') {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
$db = $this->container->get('db'); $db = $this->container->get('db');
$domainName = $args ?? null; $domainName = $args ?? null;
$registrar = $data['registrar'] ?? null;
$authInfo = $data['authInfo'] ?? null;
$transferYears = $data['transferYears'] ?? null;
if (!$domainName) { if (!$domainName) {
$this->container->get('flash')->addMessage('error', 'Please provide the domain name'); $this->container->get('flash')->addMessage('error', 'Please provide the domain name');
@ -2321,6 +2323,14 @@ class DomainsController extends Controller
$tldid = $domain['tldid']; $tldid = $domain['tldid'];
$registrar_id_domain = $domain['clid']; $registrar_id_domain = $domain['clid'];
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
if ($_SESSION["auth_roles"] != 0) {
$clid = $result['registrar_id'];
} else {
$clid = $db->selectValue('SELECT clid FROM domain WHERE name = ?', [$domainName]);
}
$domain_authinfo_id = $db->selectValue( $domain_authinfo_id = $db->selectValue(
'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1', 'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1',
[ [
@ -2358,18 +2368,15 @@ class DomainsController extends Controller
$this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer'); $this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer');
return $response->withHeader('Location', '/transfers')->withStatus(302); return $response->withHeader('Location', '/transfers')->withStatus(302);
} }
} //}
} }
public function cancelTransfer(Request $request, Response $response, $args) public function cancelTransfer(Request $request, Response $response, $args)
{ {
if ($request->getMethod() === 'POST') { //if ($request->getMethod() === 'POST') {
$data = $request->getParsedBody(); $data = $request->getParsedBody();
$db = $this->container->get('db'); $db = $this->container->get('db');
$domainName = $args ?? null; $domainName = $args ?? null;
$registrar = $data['registrar'] ?? null;
$authInfo = $data['authInfo'] ?? null;
$transferYears = $data['transferYears'] ?? null;
if (!$domainName) { if (!$domainName) {
$this->container->get('flash')->addMessage('error', 'Please provide the domain name'); $this->container->get('flash')->addMessage('error', 'Please provide the domain name');
@ -2383,6 +2390,14 @@ class DomainsController extends Controller
$tldid = $domain['tldid']; $tldid = $domain['tldid'];
$registrar_id_domain = $domain['clid']; $registrar_id_domain = $domain['clid'];
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
if ($_SESSION["auth_roles"] != 0) {
$clid = $result['registrar_id'];
} else {
$clid = $db->selectValue('SELECT clid FROM domain WHERE name = ?', [$domainName]);
}
$domain_authinfo_id = $db->selectValue( $domain_authinfo_id = $db->selectValue(
'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1', 'SELECT id FROM domain_authInfo WHERE domain_id = ? AND authtype = \'pw\' AND authinfo = ? LIMIT 1',
[ [
@ -2420,7 +2435,7 @@ class DomainsController extends Controller
$this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer'); $this->container->get('flash')->addMessage('error', 'The domain is NOT pending transfer');
return $response->withHeader('Location', '/transfers')->withStatus(302); return $response->withHeader('Location', '/transfers')->withStatus(302);
} }
} //}
} }
public function restoreDomain(Request $request, Response $response, $args) public function restoreDomain(Request $request, Response $response, $args)

View file

@ -355,14 +355,14 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="card h-100"> <div class="card h-100">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">IP Whitelisting</h5> <h5 class="card-title">IP Whitelisting <span class="text-red">*</span></h5>
<p class="card-text"> <p class="card-text">
Whitelist IP addresses for secure access. Up to 5 IP addresses (IPv4 or IPv6) can be added. Whitelist IP addresses for secure access. Up to 5 IP addresses (IPv4 or IPv6) can be added.
</p> </p>
<div id="ipWhitelistForm"> <div id="ipWhitelistForm">
<div id="ipAddressFields"> <div id="ipAddressFields">
<div class="mb-3 d-flex align-items-center"> <div class="mb-3 d-flex align-items-center">
<input type="text" class="form-control" name="ipAddress[]" autocapitalize="none"> <input type="text" class="form-control" name="ipAddress[]" autocapitalize="none" required>
<button type="button" class="btn btn-primary ms-2 add-ip">+</button> <button type="button" class="btn btn-primary ms-2 add-ip">+</button>
</div> </div>
</div> </div>

View file

@ -340,7 +340,7 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="card h-100"> <div class="card h-100">
<div class="card-body"> <div class="card-body">
<h5 class="card-title">IP Whitelisting</h5> <h5 class="card-title"> <span class="text-red">*</span></h5>
<p class="card-text"> <p class="card-text">
Whitelist IP addresses for secure access. Up to 5 IP addresses (IPv4 or IPv6) can be added. Whitelist IP addresses for secure access. Up to 5 IP addresses (IPv4 or IPv6) can be added.
</p> </p>
@ -348,7 +348,7 @@
<div id="ipAddressFields"> <div id="ipAddressFields">
{% for ip in whitelist %} {% for ip in whitelist %}
<div class="mb-3 d-flex align-items-center"> <div class="mb-3 d-flex align-items-center">
<input type="text" class="form-control" name="ipAddress[]" value="{{ ip.addr }}" autocapitalize="none"> <input type="text" class="form-control" name="ipAddress[]" value="{{ ip.addr }}" autocapitalize="none" required>
<button type="button" class="btn btn-danger ms-2 remove-ip">-</button> <button type="button" class="btn btn-danger ms-2 remove-ip">-</button>
</div> </div>
{% endfor %} {% endfor %}