Cleaned up realations regarding response classes
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
ref #132
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user