hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
5.34k stars 803 forks source link

Fix File Cleanup Bug During User Registration in registerUser Function #128

Open Lonka-Pardhu opened 5 months ago

Lonka-Pardhu commented 5 months ago

This pull request fixes a bug in the registerUser function where temporary files uploaded via multer were not being deleted if a user already exists, leading to orphaned files on the server.

The fix involves adding logic to delete these files before throwing an error when a user with the same email or username is found