Updated some nameing to fit with the rest of the models
continuous-integration/drone/pr Build is passing Details

ref #37
This commit is contained in:
Nicolai Ort 2020-12-20 16:51:59 +01:00
parent ca142376b3
commit 4a21c1fb5c
2 changed files with 9 additions and 6 deletions

View File

@ -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<UserGroup>();
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);

View File

@ -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());
}