Explorar o código

Improved interface

Taichi Masuyama %!s(int64=4) %!d(string=hai) anos
pai
achega
323a2c2b77

+ 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(),
   ];