5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 03:16:22 +00:00

validar direcciones de correo

closes #291
This commit is contained in:
f 2021-02-24 17:25:37 -03:00
parent 75cb667d1c
commit 9a8839dd93
6 changed files with 62 additions and 7 deletions

View file

@ -45,7 +45,7 @@ gem 'commonmarker'
gem 'devise'
gem 'devise-i18n'
gem 'devise_invitable'
gem 'email_address'
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
gem 'exception_notification'
gem 'fast_blank'
gem 'friendly_id'

View file

@ -6,6 +6,15 @@ GIT
rails (>= 3.0)
rake (>= 0.8.7)
GIT
remote: https://github.com/fauno/email_address
revision: 536b51f7071b68a55140c0c1726b4cd401d1c04d
branch: i18n
specs:
email_address (0.1.20)
netaddr (>= 2.0.4, < 3)
simpleidn
GEM
remote: https://rubygems.org/
remote: https://gems.sutty.nl/
@ -163,9 +172,6 @@ GEM
em-websocket (0.5.2)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
email_address (0.1.19)
netaddr (>= 2.0.4, < 3)
simpleidn
errbase (0.2.1)
erubi (1.10.0)
eventmachine (1.2.7)
@ -595,7 +601,7 @@ DEPENDENCIES
dotenv-rails
down
editorial-autogestiva-jekyll-theme
email_address
email_address!
exception_notification
factory_bot_rails
fast_blank

View file

@ -1,7 +1,5 @@
# frozen_string_literal: true
require 'open-uri'
# Usuarie de la plataforma
class Usuarie < ApplicationRecord
devise :invitable, :database_authenticatable,
@ -9,6 +7,7 @@ class Usuarie < ApplicationRecord
:confirmable, :lockable, :registerable
validates_uniqueness_of :email
validates_with EmailAddress::ActiveRecordValidator, field: :email
has_many :roles
has_many :sites, through: :roles

View file

@ -37,5 +37,15 @@ module Sutty
.rescue_responses['Pundit::NotAuthorizedError'] = :forbidden
config.active_storage.variant_processor = :vips
config.after_initialize do
I18n.available_locales.each do |locale|
translations = I18n.t(:email_address, locale: locale)
next unless translations.is_a? Hash
EmailAddress::Config.error_messages translations.transform_keys(&:to_s), locale.to_s
end
end
end
end

View file

@ -604,3 +604,23 @@ en:
url: Address
more: More heading levels
word: "If you're pasting from an hegemonic word processor, please be patient with us, it's not always simple to recover the whole format :)"
email_address:
address_unknown: "the address is unknown"
domain_does_not_accept_email: "this domain is not configured to accept email"
domain_invalid: "domain name format is incorrect"
domain_no_localhost: "localhost is not allowed for your domain name"
domain_unknown: "domain name not registered"
exceeds_size: "address is too long"
incomplete_domain: "domain name is incomplete (ie: missing .com)"
invalid_address: "format is incorrect (ie: user@example.org)"
invalid_host: "provider format is incorrect"
invalid_mailbox: "the account format is incorrect (ie: contains spaces)"
ip_address_forbidden: "IP addresses are not allowed"
ip_address_no_localhost: "localhost IP addresses are not allowed"
ipv4_address_invalid: "the address is not a valid IPv4 address"
ipv6_address_invalid: "the address is not a valid IPv6 address"
local_size_long: "the account name is too long"
local_size_short: "the account name is too short"
local_invalid: "format is incorrect"
not_allowed: "is not welcome here"
server_not_available: "the remote email server is not available"

View file

@ -617,3 +617,23 @@ es:
url: Dirección
more: Más niveles de título
word: "Si estás pegando texto desde un hegemónico editor de texto que empieza con W, por favor tenenos paciencia, no siempre es simple recuperar y respetar todo el formato :)"
email_address:
address_unknown: "la dirección es desconocida"
domain_does_not_accept_email: "el nombre de dominio no acepta correo"
domain_invalid: "el nombre de dominio no es válido"
domain_no_localhost: "no se permiten direcciones locales"
domain_unknown: "el nombre de dominio no existe"
exceeds_size: "la dirección es demasiado larga"
incomplete_domain: "el nombre de dominio está incompleto (ej. ¿falta el .com?)"
invalid_address: "la dirección no tiene el formato correcto (ej. usuarie@dominio.org)"
invalid_host: "el nombre de dominio es incorrecto"
invalid_mailbox: "el nombre de la cuenta es incorrecto (ej. tiene espacios)"
ip_address_forbidden: "no se permiten direcciones IP"
ip_address_no_localhost: "no se permiten direcciones IP locales"
ipv4_address_invalid: "no es una dirección IPv4 válida"
ipv6_address_invalid: "no es una dirección IPv6 válida"
local_size_long: "el nombre de la cuenta es muy largo"
local_size_short: "el nombre de la cuenta es muy corto"
local_invalid: "el formato es incorrecto"
not_allowed: "no es bienvenida"
server_not_available: "el proveedor no está disponible"