Prevent accidental user overwrites #139
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synapse Admin API provides Create or modify API endpoint that allows overwriting existing users by default.
Sometimes, you may want such functionality, but there is a huge change that in the vast majority of cases that will lead to accidental/unexpected overwrites.
Luckily, a new endpoint was added to the Synapse Admin API, that can be used to prevent unexpected users overwrite: https://element-hq.github.io/synapse/latest/admin_api/user_admin_api.html#check-username-availability
Please make Synapse Admin to call that endpoint before creating a new user, and if there is already existing user with this username, show a modal window with "Warning! This username is already taken. Are you certain that you intend to overwrite the existing user?" alert and options to continue (i.e., send the request), and cancel.
It would be amazing if that check could be added to the new user form near the Username field as well, so when you're entering the username, you will see something like "✔️ username is available" and "⚠️ username is already taken" messages near the input field