|
|
@@ -92,9 +92,17 @@ class ExternalAccount {
|
|
|
nameToBeRegistered = '';
|
|
|
}
|
|
|
|
|
|
- // create a new User with STATUS_ACTIVE
|
|
|
- debug(`ExternalAccount '${accountId}' is not found, it is going to be registered.`);
|
|
|
- return User.createUser(nameToBeRegistered, usernameToBeRegistered, mailToBeRegistered, undefined, undefined, User.STATUS_ACTIVE);
|
|
|
+ User.findAllUsers({status: User.statusActivate})
|
|
|
+ .then(userData => {
|
|
|
+ const userUpperLimit = Number(ExternalAccount.crowi.env['USER_UPPER_LIMIT']);
|
|
|
+ const activeUsers = userData.length;
|
|
|
+ if (userUpperLimit !== 0 && userUpperLimit <= activeUsers) {
|
|
|
+ throw new UserUpperLimitException('ユーザーが上限に達したため登録できません。');
|
|
|
+ }
|
|
|
+ // create a new User with STATUS_ACTIVE
|
|
|
+ debug(`ExternalAccount '${accountId}' is not found, it is going to be registered.`);
|
|
|
+ return User.createUser(nameToBeRegistered, usernameToBeRegistered, mailToBeRegistered, undefined, undefined, User.STATUS_ACTIVE);
|
|
|
+ });
|
|
|
})
|
|
|
.then(newUser => {
|
|
|
return this.associate(providerType, accountId, newUser);
|
|
|
@@ -155,6 +163,13 @@ class DuplicatedUsernameException {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class UserUpperLimitException {
|
|
|
+ constructor(message) {
|
|
|
+ this.name = this.constructor.name;
|
|
|
+ this.message = message;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
module.exports = function(crowi) {
|
|
|
ExternalAccount.crowi = crowi;
|
|
|
schema.loadClass(ExternalAccount);
|