mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
fix(server): catching possible errors to provide better messages to the client
This commit is contained in:
parent
babd92d6e2
commit
443a6a59ee
|
@ -325,14 +325,26 @@ export async function getUser(
|
|||
//if the user is in the auth system but not in the db, its possible that the user was created by bypassing captcha
|
||||
//since there is no data in the database anyway, we can just delete the user from the auth system
|
||||
//and ask them to sign up again
|
||||
|
||||
await FirebaseAdmin().auth().deleteUser(uid);
|
||||
throw new MonkeyError(
|
||||
404,
|
||||
"User not found in the database, but found in the auth system. We have deleted the ghost user from the auth system. Please sign up again.",
|
||||
"get user",
|
||||
uid
|
||||
);
|
||||
try {
|
||||
await FirebaseAdmin().auth().deleteUser(uid);
|
||||
throw new MonkeyError(
|
||||
404,
|
||||
"User not found in the database, but found in the auth system. We have deleted the ghost user from the auth system. Please sign up again.",
|
||||
"get user",
|
||||
uid
|
||||
);
|
||||
} catch (e) {
|
||||
if (e.code === "auth/user-not-found") {
|
||||
throw new MonkeyError(
|
||||
404,
|
||||
"User not found in the database or the auth system. Please sign up again.",
|
||||
"get user",
|
||||
uid
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue