Skip to content

Commit

Permalink
login-account-proxy: Better handle slightly malformed payloads from B…
Browse files Browse the repository at this point in the history
…ubble
  • Loading branch information
domdomegg committed May 19, 2024
1 parent f8b0108 commit 5537a07
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/login-account-proxy/src/pages/api/public/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export default apiRoute(async (
res: NextApiResponse,
) => {
// TODO: better schema validation
const data = req.body as SubmitRequest;
const data = (typeof req.body === 'string' ? JSON.parse(req.body) : req.body) as SubmitRequest;
if (typeof data.newEmail !== 'string' || typeof data.password !== 'string' || typeof data.secret !== 'string') {
console.error(`Invalid payload: ${JSON.stringify(req.body)}`);

Check warning on line 20 in apps/login-account-proxy/src/pages/api/public/submit.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
res.status(400).send({ type: 'error', message: 'Invalid payload' });
return;
}
Expand Down

0 comments on commit 5537a07

Please sign in to comment.