From 818ccf9879227d63cbe7bfe22acd41692d297791 Mon Sep 17 00:00:00 2001 From: pabois <pierreandre.boissinot@noesya.coop> Date: Fri, 17 Dec 2021 11:50:41 +0100 Subject: [PATCH] errors registration --- app/assets/stylesheets/commons/_forms.sass | 4 +++- app/models/user/with_authentication.rb | 2 +- config/locales/en.yml | 6 ++++++ config/locales/fr.yml | 6 ++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/commons/_forms.sass b/app/assets/stylesheets/commons/_forms.sass index 4b1f04f6b..a61cc00e3 100644 --- a/app/assets/stylesheets/commons/_forms.sass +++ b/app/assets/stylesheets/commons/_forms.sass @@ -1,7 +1,9 @@ .password position: relative .sfpwh-password-toggle - top: calc(50% - 6px) + top: 36px +.sfpwh-controls ~ .invalid-feedback + margin-top: 0 legend ~ * clear: left diff --git a/app/models/user/with_authentication.rb b/app/models/user/with_authentication.rb index dafe47ac0..933ba2c8f 100644 --- a/app/models/user/with_authentication.rb +++ b/app/models/user/with_authentication.rb @@ -78,7 +78,7 @@ module User::WithAuthentication def password_complexity # Regexp extracted from https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a return if password.blank? || password =~ /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#{Rails.application.config.allowed_special_chars}]).{#{Devise.password_length.first},#{Devise.password_length.last}}$/ - errors.add :password, I18n.t('activerecord.errors.models.user.password.password_strength') + errors.add :password, :password_strength end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 775168013..63a99d428 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,6 +26,12 @@ en: mobile_phone: Mobile phone picture: Profile picture role: Role + errors: + models: + user: + attributes: + password: + password_strength: doesn't match the security policy models: language: one: Language diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 571aaf22d..72edb7092 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -26,6 +26,12 @@ fr: mobile_phone: Téléphone portable picture: Photo de profil role: Rôle + errors: + models: + user: + attributes: + password: + password_strength: ne répond pas aux critères de sécurité models: language: one: Langue -- GitLab