Răsfoiți Sursa

Merge branch 'imprv/user-group-listing-api' into imprv/user-group-create-update-parent

Taichi Masuyama 4 ani în urmă
părinte
comite
afe910946d

+ 6 - 2
packages/app/src/server/models/user-group-relation.js

@@ -272,8 +272,12 @@ class UserGroupRelation {
       });
   }
 
-  static async findWithUserByGroupIds(groupIds = null) {
-    return this.find(Array.isArray(groupIds) ? { relatedGroup: { $in: groupIds } } : {})
+  static async findWithUserByGroupIds(groupIds) {
+    if (!Array.isArray(groupIds)) {
+      throw Error('groupIds must be an array');
+    }
+
+    return this.find({ relatedGroup: { $in: groupIds } })
       .populate('relatedUser');
   }
 

+ 1 - 1
packages/app/src/server/routes/apiv3/user-group-relation.js

@@ -25,7 +25,7 @@ module.exports = (crowi) => {
   const { UserGroupRelation } = crowi.models;
 
   validator.list = [
-    query('groupIds', 'groupIds must be an array').optional().isArray(),
+    query('groupIds', 'groupIds is required and must be an array').isArray(),
     query('childGroupIds', 'childGroupIds must be an array').optional().isArray(),
   ];
 

+ 1 - 1
packages/app/src/server/routes/apiv3/user-group.js

@@ -66,7 +66,7 @@ module.exports = (crowi) => {
    *                      type: object
    *                      description: a result of `UserGroup.find`
    */
-  router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
+  router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => { // TODO 85062: userGroups with no parent
     const { query } = req;
 
     // TODO 85062: improve sort