From 15e6e7ff40af75971414fe5fc9fd7c87d0fd3c51 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Sun, 6 Oct 2024 22:42:54 +0800 Subject: [PATCH 1/8] feat: Add _blank to external and feedback url --- templates/components/AppFooter.html.twig | 4 ++-- templates/security/login.html.twig | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/components/AppFooter.html.twig b/templates/components/AppFooter.html.twig index 8a64333..533548c 100644 --- a/templates/components/AppFooter.html.twig +++ b/templates/components/AppFooter.html.twig @@ -6,12 +6,12 @@
From d0142282cf5026836f32c2b117dbb94b14fb6ce0 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Sun, 6 Oct 2024 22:51:29 +0800 Subject: [PATCH 2/8] feat(feedback): Record IP if users do not login --- src/Controller/FeedbackController.php | 2 ++ templates/feedback/index.html.twig | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/Controller/FeedbackController.php b/src/Controller/FeedbackController.php index 9a8b7b5..b041738 100644 --- a/src/Controller/FeedbackController.php +++ b/src/Controller/FeedbackController.php @@ -35,11 +35,13 @@ public function index( if ($form->isSubmitted() && $form->isValid()) { // add more metadata that does not affect by requests (e.g. user agent) + // if we don't know the user, we store the IP address so we can track it. $feedback->setMetadata(array_merge( $feedback->getMetadata(), [ 'user_agent' => $request->headers->get('User-Agent'), 'user' => $user?->getUserIdentifier(), + 'ip' => null === $user ? $request->getClientIp() : null, ], )); diff --git a/templates/feedback/index.html.twig b/templates/feedback/index.html.twig index 3631ff2..35ffca2 100644 --- a/templates/feedback/index.html.twig +++ b/templates/feedback/index.html.twig @@ -12,6 +12,12 @@ {% if form is not null %} + {% if app.user is null %} +
+ 因為您沒有登入,我們還會額外記錄 IP 地址,以便追蹤回饋來源。 +
+ {% endif %} + {{ form(form) }}