Skip to content

Profile Picture Deleted When Changing Username #270

@unijaychie

Description

@unijaychie

Severity: High

  1. Causes unintended data loss (profile picture deletion).
  2. Violates user expectations and may lead to frustration or confusion.

Describe the bug
When a user changes their username on the Account Settings page, the app unexpectedly deletes the existing profile picture. This violates data integrity expectations and risks unintended data loss.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to https://app.aixblock.io/user/account.
  2. Upload a profile picture (e.g., example.jpg).
  3. Change the username (e.g., from oldusername to clangofthebell).
  4. Click Save or Update.
  5. Observe that the profile picture is deleted after the username change.

Expected behavior
Changing the username should not affect the profile picture. The picture should remain unchanged unless explicitly deleted by the user.

Videos & Screenshot

Image

https://drive.google.com/file/d/1BwR2PhIxljSkgfKCsYzgC0TGfKy9N55r/view?usp=sharing

Desktop (please complete the following information):
OS: Windows 11
Browser Chrome
Version v139.0.7258.139

Additional context
Users may lose their profile picture without warning, requiring re-upload.

Suggested Fix
Frontend Fix:

Ensure the profile picture is not cleared during username updates.
Example fix (JavaScript):

javascript

// Preserve profile picture during username update
const updateUsername = async (newUsername) => {
  const response = await fetch('/api/update-username', {
    method: 'POST',
    body: JSON.stringify({ username: newUsername }),
  });
  if (response.ok) {
    // Do NOT reset profile picture
    alert("Username updated successfully!");
  }
};

Backend Fix (Critical):

Ensure the username update API does not delete the profile picture.
Example (Node.js/Express):

javascript

app.post('/api/update-username', async (req, res) => {
  const { username } = req.body;
  const user = await User.findById(req.user.id);
  user.username = username;
  await user.save(); // Do NOT touch profilePicture field
  res.status(200).send("Username updated");
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions