CreateUser

ref #14
This commit is contained in:
Philipp Dormann 2020-12-04 18:34:24 +01:00
parent 3275b5fd80
commit b101682e3c
1 changed files with 12 additions and 13 deletions

View File

@ -37,20 +37,19 @@ export class CreateUser {
}
if (this.groupId) {
if (Array.isArray(this.groupId)) {
let found_groups = []
this.groupId.forEach(async (g) => {
const foundGroup = await getConnectionManager().get().getRepository(UserGroup).find({ id: g });
if (foundGroup) {
found_groups.push(foundGroup)
} else {
throw new UserGroupNotFoundError();
}
});
newUser.groups = found_groups
} else {
newUser.groups = await getConnectionManager().get().getRepository(UserGroup).find({ id: this.groupId });
if (!Array.isArray(this.groupId)) {
this.groupId = [this.groupId]
}
let found_groups = []
this.groupId.forEach(async (g) => {
const foundGroup = await getConnectionManager().get().getRepository(UserGroup).find({ id: g });
if (foundGroup) {
found_groups.push(foundGroup)
} else {
throw new UserGroupNotFoundError();
}
});
newUser.groups = found_groups
}
const new_uuid = uuid.v4()