in src/server/routes/resetPassword.ts [154:186]
timeUntilTokenExpiry: convertExpiresAtToExpiryTimeInMs(
encryptedState.stateHandleExpiresAt,
),
},
}),
pageTitle: 'Check Your Inbox',
});
return res.type('html').send(html);
}
return res.redirect(
303,
addQueryParamsToPath('/reset-password', state.queryParams),
);
},
);
// handler for the passcode reset password form
router.post(
'/reset-password/code',
handleAsyncErrors(async (req: Request, res: ResponseWithRequestState) => {
const { code } = req.body;
const encryptedState = readEncryptedStateCookie(req);
// make sure we have the encrypted state cookie and the code otherwise redirect to the reset page
if (encryptedState?.stateHandle && code) {
const { stateHandle, userState } = encryptedState;
try {
// check for non-existent user state
// in this case throw an error to show the user the passcode is invalid
if (userState === 'NON_EXISTENT') {
throw new OAuthError({