fix the validation again

This commit is contained in:
Kyle Drake 2013-06-21 10:48:48 -07:00
parent 4e46043aae
commit 933c354926

View file

@ -74,10 +74,13 @@ class Site < Sequel::Model
# Check for existing user
user = self.class.select(:username).filter(username: values[:username]).first
if !user.nil? || (!new? && user.id != values[:id])
user = self.class.select(:id, :username).filter(username: values[:username]).first
if user
if user.id != values[:id]
errors.add :username, 'This username is already taken. Try using another one.'
end
end
if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH)
errors.add :password, "Password must be at least #{MINIMUM_PASSWORD_LENGTH} characters."