* <Fixed how uid was generated>

* <Fixed code style>

* <Removed unnecessary downcase call>
This commit is contained in:
John Ma 2018-09-12 17:03:01 -04:00 committed by Jesus Federico
parent 074a002abf
commit 4fb1a008ca
1 changed files with 11 additions and 1 deletions

View File

@ -92,7 +92,17 @@ class User < ApplicationRecord
end
def name_chunk
name[0...3].downcase
charset = ("a".."z").to_a - %w(b i l o s) + ("2".."9").to_a - %w(5 8)
chunk = name.parameterize[0...3]
if chunk.empty?
chunk + (0...3).map { charset.to_a[rand(charset.size)] }.join
elsif chunk.length == 1
chunk + (0...2).map { charset.to_a[rand(charset.size)] }.join
elsif chunk.length == 2
chunk + (0...1).map { charset.to_a[rand(charset.size)] }.join
else
chunk
end
end
def greenlight_account?