From 77369306f10f346a310fdbef17c7ad4243469bff Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 1 Feb 2022 12:02:23 +0100
Subject: [PATCH] more explicit error message for invalid value

---
 lib/AccountManager/App/Controller.pm  | 4 ++--
 lib/AccountManager/L10N/fr.pm         | 4 ++++
 templates/web/edugain/errors.html.tt2 | 5 ++++-
 templates/web/renater/errors.html.tt2 | 5 ++++-
 4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/AccountManager/App/Controller.pm b/lib/AccountManager/App/Controller.pm
index 82c5c11..4c86d2d 100644
--- a/lib/AccountManager/App/Controller.pm
+++ b/lib/AccountManager/App/Controller.pm
@@ -138,8 +138,8 @@ sub get_sp {
     }x;
 
     return $self->abort(
-        log_message  => "Incorrect parameter format: entityid",
-        user_message => "format_entityid"
+        log_message  => "Invalid parameter: entityid",
+        user_message => "invalid_entityid"
     ) if $entityid !~ $pattern;
 
     my $db = $self->stash('db');
diff --git a/lib/AccountManager/L10N/fr.pm b/lib/AccountManager/L10N/fr.pm
index f62dfe6..b8e1086 100644
--- a/lib/AccountManager/L10N/fr.pm
+++ b/lib/AccountManager/L10N/fr.pm
@@ -296,6 +296,10 @@ msgstr "Les attributs eduPersonAffiliation et eduPersonScopedAffiliation sont va
 #: templates/web/edugain/errors.tt2.html:12 templates/web/renater/errors.tt2.html:12
 msgid "internal error"
 msgstr "erreur interne"
+#. (matches.0)
+#: templates/web/edugain/errors.html.tt2:35
+msgid "invalid parameter '%1'"
+msgstr "paramètre invalide '%1'"
 
 #: templates/web/edugain/errors.tt2.html:15 templates/web/renater/errors.tt2.html:15
 msgid "mail notification failure"
diff --git a/templates/web/edugain/errors.html.tt2 b/templates/web/edugain/errors.html.tt2
index 5dd4f96..8ab9a27 100644
--- a/templates/web/edugain/errors.html.tt2
+++ b/templates/web/edugain/errors.html.tt2
@@ -31,8 +31,11 @@
         [% ELSIF (matches = error.match('missing_(\w+)')) %]
         [% c.loc("missing parameter '[_1]'", matches.0) %]
 
+        [% ELSIF (matches = error.match('invalid_(\w+)')) %]
+        [% c.loc("invalid parameter '[_1]'", matches.0) %]
+
         [% ELSE %]
-        [% err %]
+        [% error %]
 
         [% END %]
     </p>
diff --git a/templates/web/renater/errors.html.tt2 b/templates/web/renater/errors.html.tt2
index a9ad75f..6611942 100644
--- a/templates/web/renater/errors.html.tt2
+++ b/templates/web/renater/errors.html.tt2
@@ -28,8 +28,11 @@
         [% ELSIF (matches = error.match('missing_(\w+)')) %]
         [% c.loc("missing parameter '[_1]'", matches.0) %]
 
+	[% ELSIF (matches = error.match('invalid_(\w+)')) %]
+        [% c.loc("invalid parameter '[_1]'", matches.0) %]
+
         [% ELSE %]
-        [% err %]
+        [% error %]
 
         [% END %]
     </p>
-- 
GitLab