itizawa %!s(int64=6) %!d(string=hai) anos
pai
achega
602d66b1b1
Modificáronse 1 ficheiros con 11 adicións e 11 borrados
  1. 11 11
      src/server/routes/apiv3/users.js

+ 11 - 11
src/server/routes/apiv3/users.js

@@ -26,6 +26,17 @@ module.exports = (crowi) => {
     csrfVerify: csrf,
   } = require('../../util/middlewares')(crowi);
 
+  validator.inviteEmail = [
+    // isEmail prevents line breaks, so use isString
+    body('shapedEmailList').custom((value) => {
+      const array = value.filter((value) => { return isEmail(value) });
+      if (array.length === 0) {
+        throw new Error('At least one valid email address is required');
+      }
+      return array;
+    }),
+  ];
+
   /**
    * @swagger
    *
@@ -67,17 +78,6 @@ module.exports = (crowi) => {
    *                        type: string
    *                      description: Users email that already exists
    */
-  validator.inviteEmail = [
-    // isEmail prevents line breaks, so use isString
-    body('shapedEmailList').custom((value) => {
-      const array = value.filter((value) => { return isEmail(value) });
-      if (array.length === 0) {
-        throw new Error('At least one valid email address is required');
-      }
-      return array;
-    }),
-  ];
-
   router.post('/invite', loginRequired(), adminRequired, csrf, validator.inviteEmail, ApiV3FormValidator, async(req, res) => {
     try {
       const emailList = await User.createUsersByInvitation(req.body.shapedEmailList, req.body.sendEmail);