7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/validators/anti_abuse/unique_detumbled_email_validator.rb', line 7
def validate(record)
return if record.errors.include?(:email)
return unless ::Gitlab::CurrentSettings.enforce_email_subaddress_restrictions
email = record.email
if prevent_banned_user_email_reuse?(email)
reason = 'Detumbled email is associated with a banned user'
elsif limit_normalized_email_reuse?(email)
reason = 'Detumbled email has reached the reuse limit'
else
return
end
log_failed_validation(record, reason)
record.errors.add(:email, _('is not allowed. Please enter a different email address and try again.'))
end
|