A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
"deleteUser" Firebase cloud function: added deletion of user folder from Storage, added extra checks on IDs not being empty string
gianantoniopini9f38ebd0448e
diff --git a/functions/index.js b/functions/index.jsindex 0a5319fd1..9616e946e 100644--- a/functions/index.js+++ b/functions/index.js@@ -20,6 +20,10 @@ const deleteUserFunctionHandler = async (_, { auth }) => {try {const userId = auth.uid;+ if (!userId) {+ throw new Error("Could not retrieve the user's unique ID.");+ }+const updates = {};const userResumesDataSnapshot = await admin@@ -31,7 +35,9 @@ const deleteUserFunctionHandler = async (_, { auth }) => {const userResumes = userResumesDataSnapshot.val();if (userResumes) {Object.keys(userResumes).forEach(async (resumeId) => {- updates[`resumes/${resumeId}`] = null;+ if (resumeId) {+ updates[`resumes/${resumeId}`] = null;+ }});}@@ -48,6 +54,11 @@ const deleteUserFunctionHandler = async (_, { auth }) => {await admin.database().ref().update(updates);}+ const storageUserFolderPath = `users/${userId}/`;+ await admin.storage().bucket().deleteFiles({+ prefix: storageUserFolderPath,+ });+return true;} catch (error) {throw new functions.https.HttpsError('internal', error.message);