DEV: Simplify username validation in base importer
The `UsernameValidator` does already all the hard work. No need to do any additional checks in the import script. The checks were out-of-date anyway.
This commit is contained in:
parent
9e4fb262cf
commit
b48ca9dee9
|
@ -299,16 +299,8 @@ class ImportScripts::Base
|
||||||
original_name = opts[:name]
|
original_name = opts[:name]
|
||||||
original_email = opts[:email] = opts[:email].downcase
|
original_email = opts[:email] = opts[:email].downcase
|
||||||
|
|
||||||
# Allow the || operations to work with empty strings ''
|
if !UsernameValidator.new(opts[:username]).valid_format? || !User.username_available?(opts[:username])
|
||||||
opts[:username] = nil if opts[:username].blank?
|
opts[:username] = UserNameSuggester.suggest(opts[:username].presence || opts[:name].presence || opts[:email])
|
||||||
|
|
||||||
if opts[:username].blank? ||
|
|
||||||
opts[:username].length < User.username_length.begin ||
|
|
||||||
opts[:username].length > User.username_length.end ||
|
|
||||||
!User.username_available?(opts[:username]) ||
|
|
||||||
!UsernameValidator.new(opts[:username]).valid_format?
|
|
||||||
|
|
||||||
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name].presence || opts[:email])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
unless opts[:email][EmailValidator.email_regex]
|
unless opts[:email][EmailValidator.email_regex]
|
||||||
|
|
Loading…
Reference in New Issue