From 45a8e6b4a1633acb9f59027508e30af6c8191064 Mon Sep 17 00:00:00 2001 From: Lang <7system7@gmail.com> Date: Thu, 16 Apr 2026 11:56:10 +0200 Subject: [PATCH] chg: dev: add consent checkbox to user's registration - and fix the sharing pics #4 --- src/Entity/User.php | 14 +++++++ src/Form/RegistrationFormType.php | 9 ++++ .../2026/04/Version20260416094849.php | 42 +++++++++++++++++++ templates/Game/index.html.twig | 2 +- templates/Game/play.html.twig | 2 +- templates/Official/contact.html.twig | 2 +- templates/Official/privacy.html.twig | 2 +- templates/Official/terms.html.twig | 2 +- templates/Security/forgot_password.html.twig | 2 +- templates/Security/login.html.twig | 2 +- templates/Security/profile.html.twig | 2 +- templates/Security/profile_security.html.twig | 2 +- templates/Security/register.html.twig | 21 +++++++++- 13 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 src/Migrations/2026/04/Version20260416094849.php diff --git a/src/Entity/User.php b/src/Entity/User.php index b5c6f99..070e2c4 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -78,6 +78,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, TotpTwo #[Column(length: 255, nullable: true)] private ?string $avatarPath = null; + #[Column(nullable: true)] + private ?bool $consentGiven = null; + public function getId(): ?int { @@ -243,4 +246,15 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, TotpTwo $this->backupCodes = $backupCodes; return $this; } + + public function isConsentGiven(): ?bool + { + return $this->consentGiven; + } + + public function setConsentGiven(?bool $consentGiven): self + { + $this->consentGiven = $consentGiven; + return $this; + } } diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php index d19928f..87eabd3 100644 --- a/src/Form/RegistrationFormType.php +++ b/src/Form/RegistrationFormType.php @@ -12,6 +12,7 @@ namespace App\Form; use App\Entity\User; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; @@ -19,6 +20,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\Constraints\IsTrue; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; @@ -68,6 +70,13 @@ class RegistrationFormType extends AbstractType ), ], ]) + ->add('consentGiven', CheckboxType::class, [ + 'label' => 'I have read the Privacy and Data Processing Policy and I consent to the processing of my data.', + 'mapped' => true, + 'constraints' => [ + new IsTrue(message: 'You must agree to the privacy policy to create an account.'), + ], + ]) ->add('recaptcha', RecaptchaType::class); } diff --git a/src/Migrations/2026/04/Version20260416094849.php b/src/Migrations/2026/04/Version20260416094849.php new file mode 100644 index 0000000..e085865 --- /dev/null +++ b/src/Migrations/2026/04/Version20260416094849.php @@ -0,0 +1,42 @@ + + * @category Class + * @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License + * @link www.splendidbear.org + * @since 2026. 04. 16. + */ +final class Version20260416094849 extends AbstractMigration +{ + public function getDescription(): string + { + return 'Add consent property to user entity for GDPR compliance'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE app_user ADD consent_given BOOLEAN DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE app_user DROP consent_given'); + } +} diff --git a/templates/Game/index.html.twig b/templates/Game/index.html.twig index 69b5ce7..42681df 100644 --- a/templates/Game/index.html.twig +++ b/templates/Game/index.html.twig @@ -3,7 +3,7 @@ {% block title %} - The Game{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Game/play.html.twig b/templates/Game/play.html.twig index 9f4ecb0..714451d 100644 --- a/templates/Game/play.html.twig +++ b/templates/Game/play.html.twig @@ -23,7 +23,7 @@ + content="https://{{ app.request.host }}{{ asset('/images/mine-1600x627.png') }}"/> {% endblock %} {% block stylesheets %} diff --git a/templates/Official/contact.html.twig b/templates/Official/contact.html.twig index 94efbaa..cb73098 100644 --- a/templates/Official/contact.html.twig +++ b/templates/Official/contact.html.twig @@ -3,7 +3,7 @@ {% block title %} - Contact{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Official/privacy.html.twig b/templates/Official/privacy.html.twig index 73eee1b..d5a1d2b 100644 --- a/templates/Official/privacy.html.twig +++ b/templates/Official/privacy.html.twig @@ -3,7 +3,7 @@ {% block title %} - Privacy Policy{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Official/terms.html.twig b/templates/Official/terms.html.twig index 7761870..ba05e54 100644 --- a/templates/Official/terms.html.twig +++ b/templates/Official/terms.html.twig @@ -3,7 +3,7 @@ {% block title %} - Terms of Service{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Security/forgot_password.html.twig b/templates/Security/forgot_password.html.twig index 5597995..0d83050 100644 --- a/templates/Security/forgot_password.html.twig +++ b/templates/Security/forgot_password.html.twig @@ -3,7 +3,7 @@ {% block title %} - Forgot Password{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Security/login.html.twig b/templates/Security/login.html.twig index 99765f7..7b4f19c 100644 --- a/templates/Security/login.html.twig +++ b/templates/Security/login.html.twig @@ -3,7 +3,7 @@ {% block title %} - Sign In{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Security/profile.html.twig b/templates/Security/profile.html.twig index 58defcb..3e1bd99 100644 --- a/templates/Security/profile.html.twig +++ b/templates/Security/profile.html.twig @@ -3,7 +3,7 @@ {% block title %} - Profile{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Security/profile_security.html.twig b/templates/Security/profile_security.html.twig index e0a901a..2a3af17 100644 --- a/templates/Security/profile_security.html.twig +++ b/templates/Security/profile_security.html.twig @@ -3,7 +3,7 @@ {% block title %} - Security Settings{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} diff --git a/templates/Security/register.html.twig b/templates/Security/register.html.twig index 8926717..44b67cf 100644 --- a/templates/Security/register.html.twig +++ b/templates/Security/register.html.twig @@ -3,7 +3,7 @@ {% block title %} - Register{% endblock %} {% block metas %} - {%- set _ogImage = app.request.getSchemeAndHttpHost() ~ asset('images/mine-1600x627.png') -%} + {%- set _ogImage = 'https://' ~ app.request.host ~ asset('/images/mine-1600x627.png') -%} @@ -117,6 +117,25 @@ +
+ + {% if not form.consentGiven.vars.valid %} + {% for error in form.consentGiven.vars.errors %} +

{{ error.message }}

+ {% endfor %} + {% endif %} +
+