Only validate display name when updated
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

Otherwise we needlessly fetch the validated one from LDAP every time a
model is saved.
This commit is contained in:
Râu Cao 2023-05-27 20:09:02 +02:00
parent f74227fedb
commit 445cdfa024
Signed by: raucao
GPG Key ID: 15E65F399D084BA9

View File

@ -33,7 +33,8 @@ class User < ApplicationRecord
validates_uniqueness_of :email validates_uniqueness_of :email
validates :email, email: true validates :email, email: true
validates_length_of :display_name, minimum: 3, maximum: 35, allow_blank: true validates_length_of :display_name, minimum: 3, maximum: 35, allow_blank: true,
if: -> { defined?(@display_name) }
scope :confirmed, -> { where.not(confirmed_at: nil) } scope :confirmed, -> { where.not(confirmed_at: nil) }
scope :pending, -> { where(confirmed_at: nil) } scope :pending, -> { where(confirmed_at: nil) }