Improve flash messages
This commit is contained in:
1 parent
2d72b20cad
commit
189ad45eea
6 files changed
+144
-182
No files matched your search
+23
-19
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user