|
|
@@ -389,6 +389,13 @@ module.exports = (crowi) => {
|
|
|
User.findUserByUsername(username),
|
|
|
]);
|
|
|
|
|
|
+ // check for duplicate users in groups
|
|
|
+ const isRelatedUserForGroup = await UserGroupRelation.isRelatedUserForGroup(userGroup, user);
|
|
|
+
|
|
|
+ if (isRelatedUserForGroup) {
|
|
|
+ throw new Error('The user is already joined');
|
|
|
+ }
|
|
|
+
|
|
|
const userGroupRelation = await UserGroupRelation.createRelation(userGroup, user);
|
|
|
await userGroupRelation.populate('relatedUser', User.USER_PUBLIC_FIELDS).execPopulate();
|
|
|
|