We have really weird issue, up until user 100 the username was in this format
anonymousxxx
e.g. anonymous10, anonymous55, anonymous100
However as soon as we reached over number 100 anonymous user accounts, they are now in this format:
9ab9441ad3316f5d2d35cd4807317cc
01c3b651778b7871a7640511daa8eb8
2 Likes
Think i can see why looking at this code, but it seems a bit short sighted to only allow 100 random users?
def self.find_available_username_based_on(name, allow_username = nil)
name = fix_username(name)
i = 1
attempt = name
**until attempt == allow_username || User.username_available?(attempt) || i > 100**
suffix = i.to_s
max_length = User.username_length.end - suffix.length - 1
attempt = "#{name[0..max_length]}#{suffix}"
i += 1
end
until attempt == allow_username || User.username_available?(attempt) || i > 200
attempt = SecureRandom.hex[1..SiteSetting.max_username_length]
i += 1
end
attempt
end
4 Likes
Is this an actual bug @sam ?
Stephen
(Stephen)
May 16, 2019, 5:13am
4
Surprisingly not the first time this has been reported:
Hi, this is Lisbeth from Taiwan.
We use Traditional Chinese version discourse here, and we found this bug when our anonymous username become random hex which looks creepy for friendly users LOL.
Our first 100 anonymous username are something like 1111, 1112…111100, after 111100, it will become random hex.
So I keep digging the source code, and see that anonymous user name use a user_name_suggester.suggest, it will put Anonymous in Chinese (匿名) these two words into the suggester, when it go th…
Think that last report went misunderstood, too.
4 Likes
yeah, it hasn’t been fixed, so we have to change the name every 99 times
2 Likes
I suggest we fix this @tgxworld
1 Like
sam
(Sam Saffron)
May 16, 2019, 7:16am
7
9 Likes
Thanks guys.
I was going to look at doing a change so when the username is ‘anonymous’ it works slightly different and checks for the last one created. But @sam 's solution seems a lot better.
4 Likes