// Called from a WHMCS hook when a client clicks "Manage DNS"
function paneldns_ClientAreaPage($vars) {
$serviceId = $vars['serviceid'];
// Look up the sub-client ID stored during provisioning
$subClientId = Capsule::table('tblcustomfieldsvalues')
->where('relid', $serviceId)
->where('fieldid', PANELDNS_SUBCLIENT_FIELD_ID)
->value('value');
if (!$subClientId) {
return ['error' => 'No sub-client found for this service.'];
}
$response = paneldnsApiPost('/api/v1/sub-clients/' . $subClientId . '/sso-token');
if ($response['ok']) {
header('Location: ' . $response['data']['login_url']);
exit;
}
}