From ad8b137896277c72f9c2f797716fa8d440e659a4 Mon Sep 17 00:00:00 2001 From: dodaa08 Date: Wed, 21 Jan 2026 00:02:56 +0530 Subject: [PATCH] fix: allow users to clear bio field in profile When users cleared their bio field, it remained in the database as an empty string instead of being removed. This fix ensures that empty bio values are properly unset from the database, allowing users to successfully clear their bio --- apps/meteor/server/methods/saveUserProfile.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/meteor/server/methods/saveUserProfile.ts b/apps/meteor/server/methods/saveUserProfile.ts index 00115facbf315..976edf1598fc6 100644 --- a/apps/meteor/server/methods/saveUserProfile.ts +++ b/apps/meteor/server/methods/saveUserProfile.ts @@ -90,12 +90,16 @@ async function saveUserProfile( method: 'saveUserProfile', }); } - if (settings.bio.length > MAX_BIO_LENGTH) { + const trimmedBio = settings.bio.trim(); + if (trimmedBio && trimmedBio.length > MAX_BIO_LENGTH) { throw new Meteor.Error('error-bio-size-exceeded', `Bio size exceeds ${MAX_BIO_LENGTH} characters`, { method: 'saveUserProfile', }); } - await Users.setBio(user._id, settings.bio.trim()); + if (!trimmedBio) { + unset.bio = true; + } + await Users.setBio(user._id, trimmedBio); } if (user && (settings.nickname || settings.nickname === '')) {