diff --git a/php/public/index.php b/php/public/index.php index 95f815fb..46c39786 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -205,6 +205,7 @@ $app->get('/desec', function (Request $request, Response $response, array $args) 'domain' => $configurationManager->domain, 'desec_email' => $configurationManager->desecEmail, 'desec_password' => $configurationManager->desecPassword, + 'desec_slug' => $configurationManager->desecSlug, 'is_desec_domain' => $configurationManager->isDesecDomain(), 'desec_account_registered' => $configurationManager->isDesecAccountRegistered(), 'desec_awaiting_verification' => $configurationManager->isDesecAwaitingVerification(), diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 54a77055..aa757dd5 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -213,6 +213,16 @@ class ConfigurationManager set { $this->set('desec_email', $value); } } + /** + * The subdomain slug the user last requested. Persisted across the multi-step + * registration flow so the slug input can be pre-filled when the form re-renders + * (e.g. after email verification). Not a secret; cleared once a domain is set. + */ + public string $desecSlug { + get => $this->get('desec_slug', ''); + set { $this->set('desec_slug', $value); } + } + /** * Base URL of the deSEC API. Configurable via the 'desec_api_base' config key * (configuration.json) only — intentionally NOT an environment variable — so the diff --git a/php/src/Desec/DesecManager.php b/php/src/Desec/DesecManager.php index 080e726b..0e2fb8a0 100644 --- a/php/src/Desec/DesecManager.php +++ b/php/src/Desec/DesecManager.php @@ -45,6 +45,10 @@ class DesecManager { $validatedSlug = $this->validateSlug($slug); + // Persist the requested slug so the form can pre-fill it when it re-renders on the + // next step of the flow (e.g. after email verification). Cleared once a domain is set. + $this->configurationManager->desecSlug = $validatedSlug; + [$token, $isNewAccount] = $this->obtainToken($email, $password); // An empty token means a brand-new account was created but its email is not yet @@ -62,6 +66,8 @@ class DesecManager { $this->configurationManager->aioCommunityContainers = ["caddy", "dnsmasq"]; $this->configurationManager->setDomain($domain, true); + // Registration is complete; the stored slug is no longer needed. + $this->configurationManager->desecSlug = ''; $this->updateIpIfDesecDomain(); return true; diff --git a/php/templates/includes/desec-register.twig b/php/templates/includes/desec-register.twig index 1a7ca899..148efdab 100644 --- a/php/templates/includes/desec-register.twig +++ b/php/templates/includes/desec-register.twig @@ -7,7 +7,7 @@ - + {% elseif desec_account_registered %} @@ -15,7 +15,7 @@
- +
{% else %} @@ -26,7 +26,7 @@ - +

Note: By submitting this form you agree to the deSEC terms of service. The registered domain and your deSEC account credentials are stored in the AIO configuration. After registration, set your router's DHCP DNS server to this machine's local IP address so LAN devices resolve the domain locally (see the dnsmasq documentation). Alternatively adjust the hosts files on your clients so that they can reach the server using the local ip-address.