@@ -181,6 +181,80 @@ router.get('/registry/org/:identifier',
181181 controller . ORG_SINGLE
182182)
183183router . get ( '/registry/org/:shortname/user/:username' ,
184+ /*
185+ #swagger.tags = ['Registry User']
186+ #swagger.operationId = 'registryUserSingle'
187+ #swagger.summary = "Retrieves information about a user for the specified username and organization short name (accessible to all registered users)"
188+ #swagger.description = "
189+ <h2>Access Control</h2>
190+ <p>All registered users can access this endpoint</p>
191+ <h2>Expected Behavior</h2>
192+ <p><b>Regular, CNA & Admin Users:</b> Retrieves information about a registry user in the same organization</p>
193+ <p><b>Secretariat:</b> Retrieves any registry user's information</p>"
194+ #swagger.parameters['$ref'] = [
195+ '#/components/parameters/apiEntityHeader',
196+ '#/components/parameters/apiUserHeader',
197+ '#/components/parameters/apiSecretHeader'
198+ ]
199+ #swagger.parameters['shortname'] = {
200+ description: 'The shortname of the organization'
201+ }
202+ #swagger.parameters['username'] = {
203+ description: 'The username of the registry user',
204+ schema: {
205+ type: 'string',
206+ pattern: '^[a-zA-Z0-9._@-]+$'
207+ }
208+ }
209+ #swagger.responses[200] = {
210+ description: 'Returns information about the specified registry user',
211+ content: {
212+ "application/json": {
213+ schema: { $ref: '../schemas/registry-user/get-registry-user-response.json' }
214+ }
215+ }
216+ }
217+ #swagger.responses[400] = {
218+ description: 'Bad Request',
219+ content: {
220+ "application/json": {
221+ schema: { $ref: '../schemas/errors/bad-request.json' }
222+ }
223+ }
224+ }
225+ #swagger.responses[401] = {
226+ description: 'Not Authenticated',
227+ content: {
228+ "application/json": {
229+ schema: { $ref: '../schemas/errors/generic.json' }
230+ }
231+ }
232+ }
233+ #swagger.responses[403] = {
234+ description: 'Forbidden',
235+ content: {
236+ "application/json": {
237+ schema: { $ref: '../schemas/errors/generic.json' }
238+ }
239+ }
240+ }
241+ #swagger.responses[404] = {
242+ description: 'Not Found',
243+ content: {
244+ "application/json": {
245+ schema: { $ref: '../schemas/errors/generic.json' }
246+ }
247+ }
248+ }
249+ #swagger.responses[500] = {
250+ description: 'Internal Server Error',
251+ content: {
252+ "application/json": {
253+ schema: { $ref: '../schemas/errors/generic.json' }
254+ }
255+ }
256+ }
257+ */
184258 mw . useRegistry ( ) ,
185259 mw . validateUser ,
186260 param ( [ 'shortname' ] ) . isString ( ) . trim ( ) . notEmpty ( ) . isLength ( { min : CONSTANTS . MIN_SHORTNAME_LENGTH , max : CONSTANTS . MAX_SHORTNAME_LENGTH } ) ,
@@ -208,6 +282,81 @@ router.put('/registry/org/:shortname',
208282)
209283
210284router . post ( '/registry/org/:shortname/user' ,
285+ /*
286+ #swagger.tags = ['Registry User']
287+ #swagger.operationId = 'registryUserCreateSingle'
288+ #swagger.summary = "Create a user with the provided short name as the owning organization (accessible to Admins and Secretariats)"
289+ #swagger.description = "
290+ <h2>Access Control</h2>
291+ <p>User must belong to an organization with the <b>Secretariat</b> role or be an <b>Admin</b> of the organization</p>
292+ <h2>Expected Behavior</h2>
293+ <p><b>Admin User:</b> Creates a user for the Admin's organization</p>
294+ <p><b>Secretariat:</b> Creates a user for any organization</p>"
295+ #swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
296+ #swagger.parameters['$ref'] = [
297+ '#/components/parameters/apiEntityHeader',
298+ '#/components/parameters/apiUserHeader',
299+ '#/components/parameters/apiSecretHeader'
300+ ]
301+ #swagger.requestBody = {
302+ required: true,
303+ content: {
304+ 'application/json': {
305+ schema:
306+ { $ref: '../schemas/registry-user/create-registry-user-request.json' }
307+ }
308+ }
309+ }
310+ #swagger.responses[200] = {
311+ description: 'Returns the new user information (with the secret)',
312+ content: {
313+ "application/json": {
314+ schema:
315+ { $ref: '../schemas/registry-user/create-registry-user-response.json' }
316+ }
317+ }
318+ }
319+ #swagger.responses[400] = {
320+ description: 'Bad Request',
321+ content: {
322+ "application/json": {
323+ schema: { $ref: '../schemas/errors/bad-request.json' }
324+ }
325+ }
326+ }
327+ #swagger.responses[401] = {
328+ description: 'Not Authenticated',
329+ content: {
330+ "application/json": {
331+ schema: { $ref: '../schemas/errors/generic.json' }
332+ }
333+ }
334+ }
335+ #swagger.responses[403] = {
336+ description: 'Forbidden',
337+ content: {
338+ "application/json": {
339+ schema: { $ref: '../schemas/errors/generic.json' }
340+ }
341+ }
342+ }
343+ #swagger.responses[404] = {
344+ description: 'Not Found',
345+ content: {
346+ "application/json": {
347+ schema: { $ref: '../schemas/errors/generic.json' }
348+ }
349+ }
350+ }
351+ #swagger.responses[500] = {
352+ description: 'Internal Server Error',
353+ content: {
354+ "application/json": {
355+ schema: { $ref: '../schemas/errors/generic.json' }
356+ }
357+ }
358+ }
359+ */
211360 mw . useRegistry ( ) ,
212361 mw . validateUser ,
213362 mw . onlySecretariatOrAdmin ,
@@ -229,6 +378,82 @@ router.post('/registry/org/:shortname/user',
229378 controller . USER_CREATE_SINGLE
230379)
231380router . put ( '/registry/org/:shortname/user/:username' ,
381+ /*
382+ #swagger.tags = ['Registry User']
383+ #swagger.operationId = 'registryUserUpdateSingle'
384+ #swagger.summary = "Updates information about a user for the specified username and organization shortname (accessible to all registered users)"
385+ #swagger.description = "
386+ <h2>Access Control</h2>
387+ <p>All registered users can access this endpoint</p>
388+ <h2>Expected Behavior</h2>
389+ <p><b>Regular User:</b> Updates the user's own information. Only name fields may be changed.</p>
390+ <p><b>Admin User:</b> Updates information about a user in the Admin's organization. Allowed to change all fields except org_short_name. </p>
391+ <p><b>Secretariat:</b> Updates information about a user in any organization. Allowed to change all fields.</p>"
392+ #swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
393+ #swagger.parameters['username'] = { description: 'The username of the user' }
394+ #swagger.parameters['$ref'] = [
395+ '#/components/parameters/active',
396+ '#/components/parameters/activeUserRolesAdd',
397+ '#/components/parameters/activeUserRolesRemove',
398+ '#/components/parameters/nameFirst',
399+ '#/components/parameters/nameLast',
400+ '#/components/parameters/nameMiddle',
401+ '#/components/parameters/nameSuffix',
402+ '#/components/parameters/newUsername',
403+ '#/components/parameters/orgShortname',
404+ '#/components/parameters/apiEntityHeader',
405+ '#/components/parameters/apiUserHeader',
406+ '#/components/parameters/apiSecretHeader'
407+ ]
408+ #swagger.responses[200] = {
409+ description: 'Returns the updated user information',
410+ content: {
411+ "application/json": {
412+ schema: { $ref: '../schemas/registry-user/update-registry-user-response.json' }
413+ }
414+ }
415+ }
416+ #swagger.responses[400] = {
417+ description: 'Bad Request',
418+ content: {
419+ "application/json": {
420+ schema: { $ref: '../schemas/errors/bad-request.json' }
421+ }
422+ }
423+ }
424+ #swagger.responses[401] = {
425+ description: 'Not Authenticated',
426+ content: {
427+ "application/json": {
428+ schema: { $ref: '../schemas/errors/generic.json' }
429+ }
430+ }
431+ }
432+ #swagger.responses[403] = {
433+ description: 'Forbidden',
434+ content: {
435+ "application/json": {
436+ schema: { $ref: '../schemas/errors/generic.json' }
437+ }
438+ }
439+ }
440+ #swagger.responses[404] = {
441+ description: 'Not Found',
442+ content: {
443+ "application/json": {
444+ schema: { $ref: '../schemas/errors/generic.json' }
445+ }
446+ }
447+ }
448+ #swagger.responses[500] = {
449+ description: 'Internal Server Error',
450+ content: {
451+ "application/json": {
452+ schema: { $ref: '../schemas/errors/generic.json' }
453+ }
454+ }
455+ }
456+ */
232457 mw . useRegistry ( ) ,
233458 mw . validateUser ,
234459 mw . onlyOrgWithPartnerRole ,
@@ -796,25 +1021,16 @@ router.post('/org/:shortname/user',
7961021 required: true,
7971022 content: {
7981023 'application/json': {
799- schema: {
800- oneOf: [
801- { $ref: '../schemas/user/create-user-request.json' },
802- { $ref: '../schemas/registry-user/create-registry-user-request.json' }
803- ]
804- },
1024+ schema:
1025+ { $ref: '../schemas/user/create-user-request.json' }
8051026 }
8061027 }
8071028 }
8081029 #swagger.responses[200] = {
8091030 description: 'Returns the new user information (with the secret)',
8101031 content: {
8111032 "application/json": {
812- schema: {
813- oneOf: [
814- { $ref: '../schemas/user/create-user-response.json' },
815- { $ref: '../schemas/registry-user/create-registry-user-response.json' }
816- ]
817- }
1033+ schema: { $ref: '../schemas/user/create-user-response.json' }
8181034 }
8191035 }
8201036 }
@@ -891,7 +1107,6 @@ router.get('/org/:shortname/user/:username',
8911107 #swagger.parameters['shortname'] = { description: 'The shortname of the organization' }
8921108 #swagger.parameters['username'] = { description: 'The username of the user' }
8931109 #swagger.parameters['$ref'] = [
894- '#/components/parameters/registry',
8951110 '#/components/parameters/apiEntityHeader',
8961111 '#/components/parameters/apiUserHeader',
8971112 '#/components/parameters/apiSecretHeader'
@@ -900,12 +1115,7 @@ router.get('/org/:shortname/user/:username',
9001115 description: 'Returns information about the specified user',
9011116 content: {
9021117 "application/json": {
903- schema: {
904- oneOf: [
905- { $ref: '../schemas/user/get-user-response.json' },
906- { $ref: '../schemas/registry-user/get-registry-user-response.json' }
907- ]
908- }
1118+ schema: { $ref: '../schemas/user/get-user-response.json' }
9091119 }
9101120 }
9111121 }
@@ -989,12 +1199,7 @@ router.put('/org/:shortname/user/:username',
9891199 description: 'Returns the updated user information',
9901200 content: {
9911201 "application/json": {
992- schema: {
993- oneOf: [
994- { $ref: '../schemas/user/update-user-response.json' },
995- { $ref: '../schemas/registry-user/update-registry-user-response.json' }
996- ]
997- }
1202+ schema: {$ref: '../schemas/user/update-user-response.json'}
9981203 }
9991204 }
10001205 }
0 commit comments