Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

fix: validate username before registering user

Open ricardogarim opened this issue 1 year ago • 3 comments

As per CORE-544 and as discussed internally at #rocketchat-dev, creating a new user with an invalid username (containing special characters) results in an error message, but the user is still created. This leads to an error when attempting to register again using the same email, as it is already registered.

To address this issue, I introduced a new method to validate usernames before registering users, ensuring that invalid usernames prevent user creation.

https://github.com/RocketChat/Rocket.Chat/assets/9621276/c6fa6408-bde5-4cf4-9c25-701b47d9a796


Notes:

  • We still have room to improve user registration and merge some functions that currently perform the same work. However, since the purpose of this PR is to fix the existing behavior, we'll leave other improvements for future discussions.
  • There are some differences between same validation error responses that I chose not to tackle now.

ToDo:

  • UI isn't rendering username errors at any type on registration.

ricardogarim avatar Jul 08 '24 13:07 ricardogarim

Looks like this PR is ready to merge! 🎉 If you have any trouble, please check the PR guidelines

dionisio-bot[bot] avatar Jul 08 '24 13:07 dionisio-bot[bot]

🦋 Changeset detected

Latest commit: a56bc1907558950653bd3452fb159d755fbb1e8d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 34 packages
Name Type
@rocket.chat/web-ui-registration Patch
@rocket.chat/i18n Patch
@rocket.chat/meteor Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/ui-client Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/model-typings Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jul 08 '24 13:07 changeset-bot[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 59.43%. Comparing base (1e1e849) to head (a56bc19). Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #32743   +/-   ##
========================================
  Coverage    59.43%   59.43%           
========================================
  Files         2546     2547    +1     
  Lines        63257    63265    +8     
  Branches     14236    14237    +1     
========================================
+ Hits         37596    37604    +8     
  Misses       22941    22941           
  Partials      2720     2720           
Flag Coverage Δ
unit 76.04% <100.00%> (+0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

codecov[bot] avatar Jul 08 '24 13:07 codecov[bot]