From 189ad45eea2c1711cc43faee28750f60c48d98bb Mon Sep 17 00:00:00 2001 From: julien Date: Tue, 3 Nov 2026 15:59:30 +0100 Subject: [PATCH] Improve flash messages --- config/rodauth.rb | 42 ++++--- public/css/style.css | 23 +--- views/create-account.erb | 213 ++++++++++++++------------------ views/layout.erb | 24 +--- views/login.erb | 12 ++ views/verify-account-resend.erb | 12 ++ 6 files changed, 144 insertions(+), 182 deletions(-) diff --git a/config/rodauth.rb b/config/rodauth.rb index 67f2d6a..7cf4bb9 100644 --- a/config/rodauth.rb +++ b/config/rodauth.rb @@ -31,7 +31,6 @@ class Netig # Déconnexion logout_notice_flash "Vous êtes maintenant déconnecté." - logout_redirect "/" # Création de compte create_account_page_title "Créer un compte — NETig" @@ -39,34 +38,39 @@ class Netig create_account_link_text "Créer un compte" before_create_account do - case param("kind") - when "individual" - throw_error_status( - 422, "first_name", "doit être renseigné" - ) if param("first_name").to_s.strip.empty? + first_name = param("first_name").to_s.strip + last_name = param("last_name").to_s.strip + organization_name = param("organization_name").to_s.strip - throw_error_status( - 422, "last_name", "doit être renseigné" - ) if param("last_name").to_s.strip.empty? + individual = + !first_name.empty? && + !last_name.empty? && + organization_name.empty? - when "organization" - throw_error_status( - 422, "organization_name", "doit être renseignée" - ) if param("organization_name").to_s.strip.empty? + organization = + first_name.empty? && + last_name.empty? && + !organization_name.empty? - else + unless individual || organization throw_error_status( - 422, "kind", "choisissez un type de compte" + 422, + "first_name", + "Renseignez soit le prénom et le nom, soit la dénomination." ) end end after_create_account do - member = if param("kind") == "individual" + first_name = param("first_name").to_s.strip + last_name = param("last_name").to_s.strip + organization_name = param("organization_name").to_s.strip + + member = if organization_name.empty? { kind: "individual", - first_name: param("first_name").to_s.strip, - last_name: param("last_name").to_s.strip, + first_name: first_name, + last_name: last_name, organization_name: nil } else @@ -74,7 +78,7 @@ class Netig kind: "organization", first_name: nil, last_name: nil, - organization_name: param("organization_name").to_s.strip + organization_name: organization_name } end diff --git a/public/css/style.css b/public/css/style.css index 02e2c5d..f68569b 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -37,7 +37,6 @@ --color-flash-notice-background: #294e43; --color-flash-error-background: #2c4647; --color-flash-error-border: #e6afa2; - --flash-space: 6rem; /* Ombres */ --color-shadow-light: rgb(202 210 197 / 20%); @@ -558,17 +557,10 @@ summary:focus-visible { /* Notifications ------------------------------------------------------------------------ */ -main.main--with-flash { - position: relative; -} - .flash-container { - position: absolute; - z-index: 1; - inset: 0 0 auto; display: grid; gap: 10px; - padding: 20px; + margin-block: 1.5rem; } .flash { @@ -591,15 +583,6 @@ main.main--with-flash { color: var(--color-text); } -main.main--with-flash > section:first-of-type { - padding-top: var(--flash-space); -} - -main.main--with-flash > section.page-section:first-of-type { - padding-top: - calc(var(--flash-space) + clamp(24px, 5vw, 72px)); -} - /* Tableaux ------------------------------------------------------------------------ */ @@ -685,10 +668,6 @@ footer { ------------------------------------------------------------------------ */ @media screen and (max-width: 600px) { - :root { - --flash-space: 8rem; - } - .box { margin-top: 60px; padding: 20px; diff --git a/views/create-account.erb b/views/create-account.erb index 1d13946..017d322 100644 --- a/views/create-account.erb +++ b/views/create-account.erb @@ -1,136 +1,107 @@ -<% kind = request.params["kind"] %> -<% valid_kind = %w[individual organization].include?(kind) %> -

Créer un compte

+ <% if flash["error"] || flash["notice"] %> +
+ <% if error = flash["error"] %> + + <% end %> + + <% if notice = flash["notice"] %> +

<%= notice %>

+ <% end %> +
+ <% end %> +

Créez un compte pour accéder à votre espace personnel et, si vous le souhaitez, demander à rejoindre NETig.

- <% if error = flash["error"] %> - - <% end %> - - <% unless valid_kind %> -

Quel type de compte souhaitez-vous créer ?

- - - - <% else %> -
- <%== rodauth.csrf_tag %> - - - - <% if kind == "individual" %> -

Personne physique

- - - " - required - > - - <% if error = rodauth.field_error("first_name") %> -

<%= error %>

- <% end %> - - - " - required - > - - <% if error = rodauth.field_error("last_name") %> -

<%= error %>

- <% end %> - - <% else %> -

Personne morale

- - - " - required - > - - <% if error = rodauth.field_error("organization_name") %> -

<%= error %>

- <% end %> - <% end %> - - - - - <% if error = rodauth.field_error(rodauth.login_param) %> -

<%= error %>

- <% end %> - -

- Nous vous enverrons un courriel pour vérifier votre adresse - électronique. Vous choisirez votre mot de passe à cette étape. -

- - -
+
+ <%== rodauth.csrf_tag %>

- - Changer de type de compte - + Renseignez soit le prénom et le nom d'une personne physique, + soit la dénomination d'une personne morale.

- <% end %> + + + " + > + + <% if error = rodauth.field_error("first_name") %> +

<%= error %>

+ <% end %> + + + " + > + + <% if error = rodauth.field_error("last_name") %> +

<%= error %>

+ <% end %> + + + " + > + + <% if error = rodauth.field_error("organization_name") %> +

<%= error %>

+ <% end %> + + + + + <% if error = rodauth.field_error(rodauth.login_param) %> +

<%= error %>

+ <% end %> + +

+ Nous vous enverrons un courriel pour vérifier votre adresse + électronique. Vous choisirez votre mot de passe à cette étape. +

+ + +

Vous avez déjà un compte ? diff --git a/views/layout.erb b/views/layout.erb index 1bea404..93303b7 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -36,9 +36,11 @@ Accueil NETig <% end %> + NETmail ↗ NETcloud ↗ NETgit ↗ + <% if rodauth.logged_in? %>

<%== rodauth.csrf_tag(rodauth.logout_path) %> @@ -54,25 +56,7 @@ - <% notice = flash["notice"] %> - <% error = flash["error"] %> - -
- <% if notice || error %> -
- <% if notice %> -

<%= notice %>

- <% end %> - - <% if error %> - - <% end %> -
- <% end %> - +
<%== yield %>
@@ -83,6 +67,7 @@

Mentions légales

Fait avec ❤️ et Roda !

+

* L'association NETig est en cours de constitution et n'est pas encore déclarée.

@@ -91,4 +76,3 @@ - diff --git a/views/login.erb b/views/login.erb index 1a8c46c..6b30783 100644 --- a/views/login.erb +++ b/views/login.erb @@ -2,6 +2,18 @@

Connexion

+ <% if flash["error"] || flash["notice"] %> +
+ <% if error = flash["error"] %> + + <% end %> + + <% if notice = flash["notice"] %> +

<%= notice %>

+ <% end %> +
+ <% end %> + <%== rodauth.login_form_header %> <%== rodauth.render("login-form") %> diff --git a/views/verify-account-resend.erb b/views/verify-account-resend.erb index abd213e..1824d97 100644 --- a/views/verify-account-resend.erb +++ b/views/verify-account-resend.erb @@ -2,6 +2,18 @@

Renvoyer le courriel de vérification

+ <% if flash["error"] || flash["notice"] %> +
+ <% if error = flash["error"] %> + + <% end %> + + <% if notice = flash["notice"] %> +

<%= notice %>

+ <% end %> +
+ <% end %> +