fix(apple auth): do not try to parse name if it is missing, add query parameters to logs

This commit is contained in:
Matteo Pagliazzi
2020-04-18 16:02:18 +02:00
parent 484bae40cd
commit 9364cdc2b4
3 changed files with 6 additions and 2 deletions

View File

@@ -170,6 +170,7 @@ describe('errorHandler', () => {
originalUrl: req.originalUrl,
headers: req.headers,
body: req.body,
query: req.query,
httpCode: 400,
isHandledError: true,
});

View File

@@ -160,8 +160,10 @@ api.redirectApple = {
}
let url = `/static/apple-redirect?code=${req.body.code}`;
if (req.body.user) {
const { name } = JSON.parse(req.body.user);
url += `&name=${name.firstName} ${name.lastName}`;
const parsedBody = JSON.parse(req.body.user);
if (parsedBody && parsedBody.name) {
url += `&name=${parsedBody.name.firstName} ${parsedBody.name.lastName}`;
}
}
return res.redirect(303, url);
},

View File

@@ -69,6 +69,7 @@ export default function errorHandler (err, req, res, next) { // eslint-disable-l
// don't send sensitive information that only adds noise
headers: omit(req.headers, ['x-api-key', 'cookie', 'password', 'confirmPassword']),
body: omit(req.body, ['password', 'confirmPassword']),
query: omit(req.query, ['password', 'confirmPassword']),
httpCode: responseErr.httpCode,
isHandledError: responseErr.httpCode < 500,