Skip to content

Commit

Permalink
fix: Unnecessary username validation on account profile form (#30677)
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Oct 19, 2023
1 parent 79f6388 commit 93a0859
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-files-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix unnecessary username validation on accounts profile form
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
const { email, avatar, username } = watch();

const previousEmail = user ? getUserEmailAddress(user) : '';
const previousUsername = user?.username || '';
const isUserVerified = user?.emails?.[0]?.verified ?? false;

const mutateConfirmationEmail = useMutation({
Expand All @@ -87,6 +88,10 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
return;
}

if (username === previousUsername) {
return;
}

if (!namesRegex.test(username)) {
return t('error-invalid-username');
}
Expand Down

0 comments on commit 93a0859

Please sign in to comment.