Skip to content

Commit

Permalink
Enable code to actually delete users
Browse files Browse the repository at this point in the history
  • Loading branch information
navzam committed Dec 2, 2024
1 parent 8551efc commit b181675
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ export const unconsentedUserCleanup = onSchedule("every 1 hours", async (event)
for (const doc of snapshot.docs) {
const userId = doc.id;

logger.info('Should delete user', { userId: userId });
logger.info('Processing user for deletion', { userId: userId });

// // Delete the user
// try {
// await auth.deleteUser(userId);
// logger.info('Successfully deleted user', { userId: userId });
// } catch (e) {
// if (e && typeof e === 'object' && 'code' in e && e.code === 'auth/user-not-found') {
// logger.warn('Failed to delete user because user was not found. Proceeding anyway', { userId: userId });
// } else {
// logger.error(`Failed to delete user: ${JSON.stringify(e)}`, { userId: userId });
// continue;
// }
// }
// Delete the user
try {
await auth.deleteUser(userId);
logger.info('Successfully deleted user', { userId: userId });
} catch (e) {
if (e && typeof e === 'object' && 'code' in e && e.code === 'auth/user-not-found') {
logger.warn('Failed to delete user because user was not found. Proceeding anyway', { userId: userId });
} else {
logger.error(`Failed to delete user: ${JSON.stringify(e)}`, { userId: userId });
continue;
}
}

// // Delete the user doc
// try {
// await doc.ref.delete();
// logger.info('Successfully deleted doc for user', { userId: userId });
// } catch (e) {
// logger.error(`Failed to delete doc: ${JSON.stringify(e)}`, { userId: userId });
// continue;
// }
// Delete the user doc
try {
await doc.ref.delete();
logger.info('Successfully deleted doc for user', { userId: userId });
} catch (e) {
logger.error(`Failed to delete doc: ${JSON.stringify(e)}`, { userId: userId });
continue;
}

logger.info('Finished processing user', { userId: userId });
}
Expand Down

0 comments on commit b181675

Please sign in to comment.