diff --git a/app/models/verification/letter.rb b/app/models/verification/letter.rb index a64fe7220..6a5745de2 100644 --- a/app/models/verification/letter.rb +++ b/app/models/verification/letter.rb @@ -22,6 +22,18 @@ class Verification::Letter end def verify? + letter_sent? + correct_code? + errors.blank? + end + + def letter_sent? + errors.add(:verification_code, I18n.t('verification.letter.errors.letter_not_sent')) unless + user.letter_sent_at.present? + end + + def correct_code? + errors.add(:verification_code, I18n.t('verification.letter.errors.incorect_code')) unless user.letter_verification_code == verification_code end diff --git a/config/locales/verification.en.yml b/config/locales/verification.en.yml index 3480d5a4c..aa231298f 100644 --- a/config/locales/verification.en.yml +++ b/config/locales/verification.en.yml @@ -78,12 +78,15 @@ en: title: "Security code confirmation" confirmation_code: "Enter the security code in your letter" update: - error: "Incorrect confirmation code" flash: success: "Correct code. Your account is verified" alert: unconfirmed_code: "You have not yet enter the confirmation code" verify_attemps_left: "You have reached the maximum number of letter verification tries" + errors: + letter_not_sent: "We have not sent you the letter with the code yet" + incorect_code: "Incorrect confirmation code" + address_not_found: "Address not found" verified_user: show: title: "Available information" diff --git a/config/locales/verification.es.yml b/config/locales/verification.es.yml index e500bc33d..13263c5fb 100644 --- a/config/locales/verification.es.yml +++ b/config/locales/verification.es.yml @@ -78,12 +78,18 @@ es: title: "Confirmación de código de seguridad" confirmation_code: "Introduce el código que has recibido en tu carta" update: - error: "Código de verificación incorrecto" flash: success: "Código correcto. Tu cuenta ya está verificada" alert: unconfirmed_code: "Todavía no has introducido el código de confirmación" +<<<<<<< HEAD verify_attemps_left: "Has llegado al máximo número de intentos de verificar tu carta." +======= + errors: + letter_not_sent: "Aún no te hemos enviado la carta con el código" + incorect_code: "Código de verificación incorrecto" + address_not_found: "No se ha encontrado una dirección" +>>>>>>> adds validation error for letter verification code [#395] verified_user: show: title: "Información disponible"