Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 0c2b643

Browse files
typerandomRobert
authored andcommitted
remove givenName and surname restrictions to registration data model
1 parent 23edebd commit 0c2b643

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

lib/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ web:
6767
enabled: true
6868
label: "First Name"
6969
placeholder: "First Name"
70-
required: true
70+
required: false
7171
type: "text"
7272
middleName:
7373
enabled: false
@@ -79,7 +79,7 @@ web:
7979
enabled: true
8080
label: "Last Name"
8181
placeholder: "Last Name"
82-
required: true
82+
required: false
8383
type: "text"
8484
username:
8585
enabled: false

lib/controllers/register.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,6 @@ function defaultJsonResponse(req, res) {
6969
helpers.strippedAccountResponse(req.user, res);
7070
}
7171

72-
/**
73-
* The Stormpath API requires the `givenName` and `surname` fields to be
74-
* provided, but as a convenience our framework integrations allow you to
75-
* omit this data and fill those fields with the string `UNKNOWN` - but only
76-
* if the field is not explicitly required.
77-
*
78-
* @function
79-
*
80-
* @param {Object} stormpathConfig - The express-stormpath configuration object
81-
* @param {Object} req - The http request.
82-
*/
83-
function applyDefaultAccountFields(stormpathConfig, req) {
84-
var registerFields = stormpathConfig.web.register.form.fields;
85-
86-
if ((!registerFields.givenName || !registerFields.givenName.required || !registerFields.givenName.enabled) && !req.body.givenName) {
87-
req.body.givenName = 'UNKNOWN';
88-
}
89-
90-
if ((!registerFields.surname || !registerFields.surname.required || !registerFields.surname.enabled) && !req.body.surname) {
91-
req.body.surname = 'UNKNOWN';
92-
}
93-
}
94-
9572
/**
9673
* Register a new user -- either via a JSON API, or via a browser.
9774
*
@@ -140,8 +117,6 @@ module.exports = function (req, res, next) {
140117
break;
141118

142119
case 'POST':
143-
applyDefaultAccountFields(config, req);
144-
145120
handlePreRegistration(req.body, function (err) {
146121
if (err) {
147122
return helpers.writeJsonError(res, err);
@@ -210,15 +185,6 @@ module.exports = function (req, res, next) {
210185
// to validate the user's data and create their account.
211186
case 'POST':
212187
async.waterfall([
213-
// What we'll do here is simply set default values for `givenName` and
214-
// `surname`, because these value are annoying to set if you don't
215-
// care about them. Eventually Stormpath is going to remove these
216-
// required fields, but for now this is a decent workaround to ensure
217-
// people don't have to deal with that stuff.
218-
function (callback) {
219-
applyDefaultAccountFields(config, req);
220-
callback();
221-
},
222188
function (callback) {
223189
handlePreRegistration(req.body, function (err) {
224190
if (err) {

0 commit comments

Comments
 (0)