Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-drinks-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue where it was not possible to save nickname and bio as empty in user profile
4 changes: 2 additions & 2 deletions apps/meteor/server/methods/saveUserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function saveUserProfile(
await setUserStatusMethod(this.userId, settings.statusType as UserStatus, undefined);
}

if (user && settings.bio) {
if (user && (settings.bio || settings.bio === '')) {
if (typeof settings.bio !== 'string') {
throw new Meteor.Error('error-invalid-field', 'bio', {
method: 'saveUserProfile',
Expand All @@ -100,7 +100,7 @@ async function saveUserProfile(
await Users.setBio(user._id, settings.bio.trim());
}

if (user && settings.nickname) {
if (user && (settings.nickname || settings.nickname === '')) {
if (typeof settings.nickname !== 'string') {
throw new Meteor.Error('error-invalid-field', 'nickname', {
method: 'saveUserProfile',
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/tests/data/users.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const createUser = <TUser extends IUser>(
name?: string;
password?: string;
freeSwitchExtension?: string;
bio?: string;
nickname?: string;
} = {},
config?: IRequestConfig,
) =>
Expand Down
27 changes: 27 additions & 0 deletions apps/meteor/tests/end-to-end/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,33 @@ describe('[Users]', () => {
});
});

it('should be able to erase bio and nickname', async () => {
const user = await createUser({
bio: `edited-bio-test`,
nickname: `edited-nickname-test`,
});
const userCredentials = await login(user.username, password);

await request
.post(api('users.updateOwnBasicInfo'))
.set(userCredentials)
.send({
data: {
bio: '',
nickname: '',
},
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.property('success', true);
});

const userData = await getUserByUsername(user.username);
expect(userData).to.not.have.property('bio');
expect(userData).to.not.have.property('nickname');
});

describe('[Password Policy]', () => {
before(async () => {
await updateSetting('Accounts_AllowPasswordChange', true);
Expand Down
Loading