Try harder to create unique usernames.
The previous version added 16 bits of entropy to the username, which isn't all that much. Due to the birthday paradox, it would be enough to create ~256 users with the same prefix to get a collision. Trying that would probably fail later on, and not create security issues... but it just seems better to be on the safe side here.
This commit is contained in:
parent
8828b25a8f
commit
2134024155
|
@ -39,8 +39,7 @@ export const createUser = functions
|
|||
const name = cleanDisplayName(rawName)
|
||||
let username = cleanUsername(name)
|
||||
|
||||
const sameNameUser = await getUserByUsername(username)
|
||||
if (sameNameUser) {
|
||||
while (await getUserByUsername(username)) {
|
||||
username += randomString(4)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user