diff --git a/src/models/actions/CreateUser.ts b/src/models/actions/CreateUser.ts index 1f80ee3..041bd8e 100644 --- a/src/models/actions/CreateUser.ts +++ b/src/models/actions/CreateUser.ts @@ -67,7 +67,7 @@ export class CreateUser { * Optional. */ @IsOptional() - group?: number[] | number + groups?: number[] | number //TODO: ProfilePics @@ -95,13 +95,16 @@ export class CreateUser { return newUser; } + /** + * Get's all groups for this user by their id's; + */ public async getGroups() { - if (!this.group) { return null; } + if (!this.groups) { return null; } let groups = new Array(); - if (!Array.isArray(this.group)) { - this.group = [this.group] + if (!Array.isArray(this.groups)) { + this.groups = [this.groups] } - for (let group of this.group) { + for (let group of this.groups) { let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group }); if (!found) { throw new UserGroupNotFoundError(); } groups.push(found); diff --git a/src/seeds/SeedUsers.ts b/src/seeds/SeedUsers.ts index dae3b17..38027dd 100644 --- a/src/seeds/SeedUsers.ts +++ b/src/seeds/SeedUsers.ts @@ -29,7 +29,7 @@ export default class SeedUsers implements Seeder { initialUser.lastname = "demo"; initialUser.username = "demo"; initialUser.password = "demo"; - initialUser.group = group; + initialUser.groups = group; return await connection.getRepository(User).save(await initialUser.toUser()); }