Cleaned up realations regarding response classes
All checks were successful
continuous-integration/drone/pr Build is passing

ref #132
This commit is contained in:
2021-01-30 16:19:42 +01:00
parent 8dc2810c0c
commit ff7406e71a
16 changed files with 56 additions and 42 deletions

View File

@@ -6,10 +6,10 @@ import {
IsString
} from "class-validator";
import { User } from '../entities/User';
import { UserGroup } from '../entities/UserGroup';
import { ResponseObjectType } from '../enums/ResponseObjectType';
import { IResponse } from './IResponse';
import { ResponsePrincipal } from './ResponsePrincipal';
import { ResponseUserGroup } from './ResponseUserGroup';
/**
* Defines the user response.
@@ -74,7 +74,7 @@ export class ResponseUser extends ResponsePrincipal implements IResponse {
*/
@IsArray()
@IsOptional()
groups: UserGroup[];
groups: ResponseUserGroup[];
/**
* The user's permissions.
@@ -98,10 +98,13 @@ export class ResponseUser extends ResponsePrincipal implements IResponse {
this.username = user.username;
this.enabled = user.enabled;
this.profilePic = user.profilePic;
this.groups = user.groups;
this.groups = new Array<ResponseUserGroup>();
this.permissions = user.allPermissions;
if (this.groups) {
this.groups.forEach(function (g) { delete g.permissions });
if (user.groups) {
for (let group of user.groups) {
delete group.permissions;
this.groups.push(group.toResponse());
}
}
}
}