diff --git a/php/src/Desec/DesecManager.php b/php/src/Desec/DesecManager.php index f6bb7531..080e726b 100644 --- a/php/src/Desec/DesecManager.php +++ b/php/src/Desec/DesecManager.php @@ -99,12 +99,20 @@ class DesecManager { if ($this->configurationManager->isDesecAwaitingVerification()) { $storedEmail = $this->configurationManager->desecEmail; // Prefer a freshly entered password (e.g. the user changed it), else the generated one. - $loginPassword = $validatedPassword !== '' ? $validatedPassword : $this->configurationManager->desecPassword; + $userSuppliedPassword = $validatedPassword !== ''; + $loginPassword = $userSuppliedPassword ? $validatedPassword : $this->configurationManager->desecPassword; $token = $this->loginAfterVerification($storedEmail, $loginPassword); // Storing the token flips the state from "awaiting verification" to "account // registered" (see ConfigurationManager::isDesecAwaitingVerification()). $this->configurationManager->desecToken = $token; - return [$token, true]; + // If the user logged in with their own password (the email already had a deSEC + // account, so no AIO account was created), the previously generated password is + // wrong and must not be persisted or later revealed. Clear it so a stored, + // non-empty password reliably means "AIO generated this account". + if ($userSuppliedPassword) { + $this->configurationManager->desecPassword = ''; + } + return [$token, !$userSuppliedPassword]; } $validatedEmail = $this->validateEmail($email); diff --git a/php/templates/containers.twig b/php/templates/containers.twig index 7f27ccf6..6284ff14 100644 --- a/php/templates/containers.twig +++ b/php/templates/containers.twig @@ -404,10 +404,18 @@ {% if is_desec_domain %}

deSEC account credentials

-

Your domain {{ domain }} is managed via deSEC. Below are your deSEC account credentials. You can use them to log in at desec.io to manage your domain directly.

-

Email: {{ desec_email }}

-

Reveal deSEC password{{ desec_password }}

-

Please save these credentials in a safe place.

+ {% if desec_password %} + {# AIO created this account, so it generated and stored the password. + Show it so the user can log in at desec.io if they ever need to. #} +

Your domain {{ domain }} is managed via deSEC. Below are your deSEC account credentials. You can use them to log in at desec.io to manage your domain directly.

+

Email: {{ desec_email }}

+

Reveal deSEC password{{ desec_password }}

+

Please save these credentials in a safe place.

+ {% else %} + {# The user logged in with their own existing deSEC account; AIO never + stored their password, so there is nothing to reveal. #} +

Your domain {{ domain }} is managed via your existing deSEC account ({{ desec_email }}). Log in at desec.io with your own password to manage your domain directly.

+ {% endif %} {% endif %} {% if is_backup_section_enabled == false %}