-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.ts
More file actions
27 lines (25 loc) · 826 Bytes
/
Copy pathdelete.ts
File metadata and controls
27 lines (25 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as functions from "firebase-functions/v1";
import * as admin from "firebase-admin";
import * as logger from "firebase-functions/logger";
export const cleanupDeletedUserFirestoreData = functions
.runWith({
maxInstances: 1
})
.region("asia-northeast3")
.auth
.user()
.onDelete(async (user) => {
const uid = user.uid;
try {
const userDocRef = admin.firestore().doc(`users/${uid}`);
await admin.firestore().recursiveDelete(userDocRef);
logger.info("Deleted Firestore user data after Auth user deletion", { uid });
} catch (error) {
logger.error("Failed to delete Firestore user data after Auth user deletion", {
uid,
error
});
throw error;
}
}
);