@@ -452,7 +452,7 @@ async function updateOrg (req, res, next) {
452452/**
453453 * Creates a user only if the org exists and
454454 * the user does not exist for the specified shortname and username
455- * Called by POST /api/org/{shortname}/user
455+ * Called by POST /api/registry/org/{shortname}/user, POST /api/ org/{shortname}/user
456456 **/
457457async function createUser ( req , res , next ) {
458458 const session = await mongoose . startSession ( )
@@ -461,6 +461,7 @@ async function createUser (req, res, next) {
461461 const userRepo = req . ctx . repositories . getBaseUserRepository ( )
462462 const orgRepo = req . ctx . repositories . getBaseOrgRepository ( )
463463 const orgShortName = req . ctx . params . shortname
464+ const constants = getConstants ( )
464465 let returnValue
465466
466467 // Check to make sure Org Exists first
@@ -486,6 +487,9 @@ async function createUser (req, res, next) {
486487 if ( body ?. role && typeof body ?. role !== 'string' ) {
487488 return res . status ( 400 ) . json ( { message : 'Parameters were invalid' , details : [ { param : 'role' , msg : 'Parameter must be a string' } ] } )
488489 }
490+ if ( body ?. role && ! constants . USER_ROLES . includes ( body ?. role ) ) {
491+ return res . status ( 400 ) . json ( { message : 'Parameters were invalid' , details : [ { param : 'role' , msg : `Role must be one of the following: ${ constants . USER_ROLES } ` } ] } )
492+ }
489493 if ( ! result . isValid ) {
490494 logger . error ( JSON . stringify ( { uuid : req . ctx . uuid , message : 'User JSON schema validation FAILED.' } ) )
491495 await session . abortTransaction ( )
@@ -548,7 +552,7 @@ async function createUser (req, res, next) {
548552/**
549553 * Updates a user only if the user exist for the specified username.
550554 * If no user exists, it does not create the user.
551- * Called by PUT /org/{shortname}/user/{username}
555+ * Called by PUT /org/{shortname}/user/{username}, PUT /org/{shortname}/user/{username}
552556 **/
553557async function updateUser ( req , res , next ) {
554558 const session = await mongoose . startSession ( )
0 commit comments