Skip to content
Snippets Groups Projects
Commit b2e86c36 authored by ziggy's avatar ziggy
Browse files

check if domain exists only if user account has a domain

parent 77a4ef68
Branches rails6
No related tags found
1 merge request!1DRAFT: Rails6
......@@ -142,7 +142,7 @@ module UserUsername
def validate_username
if username_changed?
# update_email if self.respond_to?(:email) TODO: if and only if email is linked to username
if defined?(Domain) && Domain.find_by(domain: self.domain).nil?
if defined?(Domain) && self.domain.present? && Domain.find_by(domain: self.domain).nil?
errors.add :base, I18n.t('domain_invalid')
end
if User.username_taken?(self.username, self.domain) && errors[:username].empty?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment