Skip to content

Commit

Permalink
fix: log password update/reset errors with consistent metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
rupl committed Nov 11, 2021
1 parent 9689e8b commit 70f8769
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion api/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest('Request is missing parameters (old_password or new_password)');
Expand All @@ -611,6 +615,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest('New password does not meet requirements');
Expand All @@ -625,6 +633,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest('New password does not meet requirements');
Expand All @@ -638,6 +650,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest('The old password is wrong');
Expand All @@ -652,6 +668,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest('New password must be different than previous passwords');
Expand Down Expand Up @@ -1486,6 +1506,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest(resetLinkInvalidMessage);
Expand All @@ -1499,6 +1523,10 @@ module.exports = {
request,
security: true,
fail: true,
user: {
id: user.id,
email: user.email,
},
},
);
throw Boom.badRequest(cannotResetPasswordMessage);
Expand Down Expand Up @@ -1587,7 +1615,7 @@ module.exports = {
// Update user in DB.
await user.save().then(() => {
logger.info(
'[UserController->resetPassword] Password updated successfully',
'[UserController->resetPassword] Password updated successfully.',
{
request,
security: true,
Expand Down

0 comments on commit 70f8769

Please # to comment.