•Published: Nov 24, 2020
In most chat apps, it's essential to be able to tell the difference between users. Though the user ids are always different, by default Stream Chat allows users to have the same name for display. This can be an issue since a user could impersonate another or choose the same name by coincidence, causing confusion.
To help with this possible issue, we've introduced a new app setting called
enforce_unique_usernames. By using this new setting, you can block users from having the same username within the whole app or within a team if your app is multi-tenant. Any attempts to use an existing username will result in a duplicate username error.
When this setting is enabled, it won't affect existing users with duplicate usernames. Also, before checking if two usernames are equal, the system will first convert them to lower case and remove white spaces as well as other special characters. That means "John Doe" is considered a duplicate of "john doe", "john.doe", etc.
Within The App
To enforce unique usernames within the whole app, set the app setting
enforce_unique_usernames to "app" like below.
We're happy to bring yet another feature to help Stream Chat fit your app's requirements. For more information about this new feature, see the documentation on unique usernames. If you need help or have specific feedback about this feature, please leave a comment on the documentation page.