Browse Source

fix isUserCountExceedsUpperLimit

Seiya Tashiro 7 years ago
parent
commit
b8b7a904f6
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/server/models/user.js

+ 8 - 6
src/server/models/user.js

@@ -506,16 +506,18 @@ module.exports = function(crowi) {
   };
 
   userSchema.statics.isUserCountExceedsUpperLimit = async function() {
-    let isUserCountExceedsUpperLimit = false;
-    const User = this;
     const Config = crowi.model('Config');
     const userUpperLimit = Config.userUpperLimit(crowi);
-    const activeUsers = await User.countListByStatus(STATUS_ACTIVE);
-    if (userUpperLimit !== 0 && userUpperLimit <= activeUsers.length) {
-      isUserCountExceedsUpperLimit = true;
+    if (userUpperLimit === 0) {
+      return false;
     }
 
-    return isUserCountExceedsUpperLimit;
+    const activeUsers = await this.countListByStatus(STATUS_ACTIVE);
+    if (userUpperLimit !== 0 && userUpperLimit <= activeUsers) {
+      return true;
+    }
+
+    return false;
   };
 
   userSchema.statics.countListByStatus = async function(status) {