Fix logic to not delete user if DB goes down (#3171)

This commit is contained in:
Bruce Berrios 2022-06-20 10:10:43 -04:00 committed by GitHub
parent ae300bfa94
commit 6a3f01f6a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,13 +103,17 @@ export async function getUser(
try {
userInfo = await UserDAL.getUser(uid, "get user");
} catch (e) {
await admin.auth().deleteUser(uid);
throw new MonkeyError(
404,
"User not found. Please try to sign up again.",
"get user",
uid
);
if (e.status === 404) {
await admin.auth().deleteUser(uid);
throw new MonkeyError(
404,
"User not found. Please try to sign up again.",
"get user",
uid
);
}
throw e;
}
const agentLog = buildAgentLog(req);