From 0dce1e50f2b9faeffc0edb880638d85b5b33e9e4 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:28:07 +0200 Subject: [PATCH] [Users] Add a reasonable length limit on emails The spec allows for addresses up to 255. A limit of 100 impacts 3 users right now --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index d0449197c..3444b3cbc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -62,6 +62,7 @@ class User < ApplicationRecord validates :email, presence: { if: :enable_email_verification? } validates :email, uniqueness: { case_sensitive: false, if: :enable_email_verification? } validates :email, format: { with: /\A.+@[^ ,;@]+\.[^ ,;@]+\z/, if: :enable_email_verification? } + validates :email, length: { maximum: 100 } validate :validate_email_address_allowed, on: [:create, :update], if: ->(rec) { (rec.new_record? && rec.email.present?) || (rec.email.present? && rec.email_changed?) } validates :name, user_name: true, on: :create