From 174e449202bfb0e8fe5798338d9ddfe8cbc112cc Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 28 Aug 2016 19:00:13 +0200 Subject: [PATCH] remove givenName and surname restrictions to registration data model --- lib/controllers/register.js | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/lib/controllers/register.js b/lib/controllers/register.js index 625ba354..da8b5f35 100644 --- a/lib/controllers/register.js +++ b/lib/controllers/register.js @@ -69,29 +69,6 @@ function defaultJsonResponse(req, res) { helpers.strippedAccountResponse(req.user, res); } -/** - * The Stormpath API requires the `givenName` and `surname` fields to be - * provided, but as a convenience our framework integrations allow you to - * omit this data and fill those fields with the string `UNKNOWN` - but only - * if the field is not explicitly required. - * - * @function - * - * @param {Object} stormpathConfig - The express-stormpath configuration object - * @param {Object} req - The http request. - */ -function applyDefaultAccountFields(stormpathConfig, req) { - var registerFields = stormpathConfig.web.register.form.fields; - - if ((!registerFields.givenName || !registerFields.givenName.required || !registerFields.givenName.enabled) && !req.body.givenName) { - req.body.givenName = 'UNKNOWN'; - } - - if ((!registerFields.surname || !registerFields.surname.required || !registerFields.surname.enabled) && !req.body.surname) { - req.body.surname = 'UNKNOWN'; - } -} - /** * Register a new user -- either via a JSON API, or via a browser. * @@ -140,8 +117,6 @@ module.exports = function (req, res, next) { break; case 'POST': - applyDefaultAccountFields(config, req); - handlePreRegistration(req.body, function (err) { if (err) { return helpers.writeJsonError(res, err); @@ -210,15 +185,6 @@ module.exports = function (req, res, next) { // to validate the user's data and create their account. case 'POST': async.waterfall([ - // What we'll do here is simply set default values for `givenName` and - // `surname`, because these value are annoying to set if you don't - // care about them. Eventually Stormpath is going to remove these - // required fields, but for now this is a decent workaround to ensure - // people don't have to deal with that stuff. - function (callback) { - applyDefaultAccountFields(config, req); - callback(); - }, function (callback) { handlePreRegistration(req.body, function (err) { if (err) {