Switched to accepting ids (numbers/number arrays) feature/90-accept_objects #101

Merged
niggl merged 26 commits from feature/90-accept_objects into dev 2021-01-15 17:57:47 +00:00
Showing only changes of commit aa0fd9cafd - Show all commits

View File

@ -79,11 +79,10 @@ export class UpdateUser {
enabled: boolean = true;
/**
* The updated user's groups.
* This just has to contain the group's id - everything else won't be changed.
* The updated user's groups' ids.
*/
@IsOptional()
groups?: UserGroup[]
groups?: number | number[]
/**
* The user's profile pic (or rather a url pointing to it).
@ -124,7 +123,7 @@ export class UpdateUser {
}
/**
* Loads the updated user's groups based on their ids.
* Get's all groups for this user by their id's;
*/
public async getGroups() {
if (!this.groups) { return null; }
@ -133,7 +132,7 @@ export class UpdateUser {
this.groups = [this.groups]
}
for (let group of this.groups) {
let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group.id });
let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group });
if (!found) { throw new UserGroupNotFoundError(); }
groups.push(found);
}