Skip to content

Commit

Permalink
fix: require family/given names when creating users via API
Browse files Browse the repository at this point in the history
  • Loading branch information
rupl committed Dec 9, 2021
1 parent f4f0060 commit 662b703
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions api/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ module.exports = {
throw Boom.badRequest('Missing field: email');
}

// Does the payload contain a given name?
if (!request.payload.given_name) {
logger.warn(
'[UserController->create] Registration failed. No given name provided.',
{
request,
security: true,
fail: true,
},
);
throw Boom.badRequest('Missing field: given_name');
}

// Does the payload contain a family name?
if (!request.payload.family_name) {
logger.warn(
'[UserController->create] Registration failed. No family name provided.',
{
request,
security: true,
fail: true,
},
);
throw Boom.badRequest('Missing field: family_name');
}

// Look for the email address in our DB.
// We cannot proceed if we find a match.
const existingUser = await User.findOne({ 'emails.email': request.payload.email });
Expand Down

0 comments on commit 662b703

Please # to comment.