From 3c16317708a5bb0df594238499afa7040b041d25 Mon Sep 17 00:00:00 2001 From: Jesse Smick Date: Wed, 22 Feb 2017 20:27:38 -0800 Subject: [PATCH 1/2] Convert emails to lowercase when saving --- routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes.js b/routes.js index 9a6b460..7ed89f9 100644 --- a/routes.js +++ b/routes.js @@ -73,7 +73,7 @@ module.exports = (app, logger) => { firstName: body.firstName, lastName: body.lastName, studentId: body.studentId, - email: body.email, + email: body.email.toLowerCase(), mailchimp: !!body.mailchimp, // Convert to boolean if not already github: body.githubUsername } From 29a61a31b9cb7f11f6cca26aebc59214f7cf011d Mon Sep 17 00:00:00 2001 From: Jesse Smick Date: Wed, 22 Feb 2017 20:33:05 -0800 Subject: [PATCH 2/2] Set default values for form data to empty string Fixes errors if form fields are not sent in the request --- routes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/routes.js b/routes.js index 7ed89f9..8a31c71 100644 --- a/routes.js +++ b/routes.js @@ -31,7 +31,7 @@ module.exports = (app, logger) => { // Github actions logger.info('Request body', req.body) let response = JSON.parse(ajaxResponse) // Get a copy - let githubUsername = req.body.githubUsername + let githubUsername = req.body.githubUsername || '' if (githubUsername === '') { next() @@ -70,12 +70,12 @@ module.exports = (app, logger) => { let body = req.body let userObj = { - firstName: body.firstName, - lastName: body.lastName, - studentId: body.studentId, - email: body.email.toLowerCase(), + firstName: body.firstName || '', + lastName: body.lastName || '', + studentId: body.studentId || '', + email: (body.email || '').toLowerCase(), mailchimp: !!body.mailchimp, // Convert to boolean if not already - github: body.githubUsername + github: body.githubUsername || '' } // Search for the user email.