zorchenhimer / MovieNight

Single instance video streaming server with integrated chat.
https://discord.gg/F2VSgjJ
MIT License
683 stars 87 forks source link

Move name checking into MovieNight/common #50

Closed joeyak closed 5 years ago

joeyak commented 5 years ago

Move name checking logic into MovieNight/common so the front end can also validate name via the wasm module. This will allow the same checking on both sides and save the UI a trip via websockets and showing possible errors. Keep the validation in the server since messages can still be send directly from the js websocket.

zorchenhimer commented 5 years ago

Do you mean also checking for name collisions? I'm not sure that can be shared between the server and wasm client. Both have their own lists of names and would need different logic to check both.

That said, I've moved the syntax validation of the name with commit 49e997c.

joeyak commented 5 years ago

So, with the changes to colors I am working on in #45 and what we talked about on discord, there is also a name check for not being colors. Then there is the range of 3-35. But I am closing this since the function as added to common.

joeyak commented 5 years ago
func IsValidName(name string) bool {
    return 3 <= len(name) && len(name) <= 36 &&
        usernameRegex.MatchString(name) && !IsValidColor(name)
}
joeyak commented 5 years ago

@zorchenhimer the answer is no on checking name collisions. The front end names are just for visual and should not be checked.