mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
added catch, disabled cache for send verification email
This commit is contained in:
parent
588e7efed8
commit
f29db00949
|
@ -63,7 +63,19 @@ export async function sendVerificationEmail(
|
|||
req: MonkeyTypes.Request
|
||||
): Promise<MonkeyResponse> {
|
||||
const { email, uid } = req.ctx.decodedToken;
|
||||
const isVerified = (await admin.auth().getUser(uid)).emailVerified;
|
||||
const isVerified = (
|
||||
await admin
|
||||
.auth()
|
||||
.getUser("uid")
|
||||
.catch((e) => {
|
||||
throw new MonkeyError(
|
||||
500, // this should never happen, but it does. it mightve been caused by auth token cache, will see if disabling cache fixes it
|
||||
"Auth user not found, even though the token got decoded",
|
||||
JSON.stringify({ uid, email, stack: e.stack }),
|
||||
uid
|
||||
);
|
||||
})
|
||||
).emailVerified;
|
||||
if (isVerified === true) {
|
||||
throw new MonkeyError(400, "Email already verified");
|
||||
}
|
||||
|
|
|
@ -593,7 +593,9 @@ router.post(
|
|||
|
||||
router.get(
|
||||
"/verificationEmail",
|
||||
authenticateRequest(),
|
||||
authenticateRequest({
|
||||
noCache: true,
|
||||
}),
|
||||
RateLimit.userRequestVerificationEmail,
|
||||
asyncHandler(UserController.sendVerificationEmail)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue