Hotfix: Missing relation bug
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
de36a24191
commit
6e6979cfe3
@ -138,8 +138,10 @@ export class User extends Principal {
|
|||||||
|
|
||||||
if (!this.groups) { return returnPermissions; }
|
if (!this.groups) { return returnPermissions; }
|
||||||
for (let group of this.groups) {
|
for (let group of this.groups) {
|
||||||
for (let permission of group.permissions) {
|
if (group.permissions) {
|
||||||
returnPermissions.push(permission);
|
for (let permission of group.permissions) {
|
||||||
|
returnPermissions.push(permission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnPermissions;
|
return returnPermissions;
|
||||||
@ -159,8 +161,10 @@ export class User extends Principal {
|
|||||||
|
|
||||||
if (!this.groups) { return returnPermissions; }
|
if (!this.groups) { return returnPermissions; }
|
||||||
for (let group of this.groups) {
|
for (let group of this.groups) {
|
||||||
for (let permission of group.permissions) {
|
if (group.permissions) {
|
||||||
returnPermissions.push(permission.toString());
|
for (let permission of group.permissions) {
|
||||||
|
returnPermissions.push(permission.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Array.from(new Set(returnPermissions));
|
return Array.from(new Set(returnPermissions));
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { ChildEntity, Column } from "typeorm";
|
import { ChildEntity, Column } from "typeorm";
|
||||||
|
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
||||||
import { ResponseUserGroup } from '../responses/ResponseUserGroup';
|
import { ResponseUserGroup } from '../responses/ResponseUserGroup';
|
||||||
import { Principal } from './Principal';
|
import { Principal } from './Principal';
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ export class UserGroup extends Principal {
|
|||||||
/**
|
/**
|
||||||
* Turns this entity into it's response class.
|
* Turns this entity into it's response class.
|
||||||
*/
|
*/
|
||||||
public toResponse(): ResponseUserGroup {
|
public toResponse(): ResponsePrincipal {
|
||||||
return new ResponseUserGroup(this);
|
return new ResponseUserGroup(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,8 +6,8 @@ import {
|
|||||||
IsString
|
IsString
|
||||||
} from "class-validator";
|
} from "class-validator";
|
||||||
import { User } from '../entities/User';
|
import { User } from '../entities/User';
|
||||||
|
import { UserGroup } from '../entities/UserGroup';
|
||||||
import { ResponsePrincipal } from './ResponsePrincipal';
|
import { ResponsePrincipal } from './ResponsePrincipal';
|
||||||
import { ResponseUserGroup } from './ResponseUserGroup';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the user response.
|
* Defines the user response.
|
||||||
@ -66,7 +66,7 @@ export class ResponseUser extends ResponsePrincipal {
|
|||||||
*/
|
*/
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
groups: ResponseUserGroup[];
|
groups: UserGroup[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user's permissions.
|
* The user's permissions.
|
||||||
@ -90,12 +90,10 @@ export class ResponseUser extends ResponsePrincipal {
|
|||||||
this.username = user.username;
|
this.username = user.username;
|
||||||
this.enabled = user.enabled;
|
this.enabled = user.enabled;
|
||||||
this.profilePic = user.profilePic;
|
this.profilePic = user.profilePic;
|
||||||
if (user.groups) {
|
this.groups = user.groups;
|
||||||
for (let group of user.groups) {
|
|
||||||
this.groups.push(group.toResponse());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.permissions = user.allPermissions;
|
this.permissions = user.allPermissions;
|
||||||
this.groups.forEach(function (g) { delete g.permissions });
|
if (this.groups) {
|
||||||
|
this.groups.forEach(function (g) { delete g.permissions });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
||||||
|
import { Permission } from '../entities/Permission';
|
||||||
import { UserGroup } from '../entities/UserGroup';
|
import { UserGroup } from '../entities/UserGroup';
|
||||||
import { ResponsePermission } from './ResponsePermission';
|
|
||||||
import { ResponsePrincipal } from './ResponsePrincipal';
|
import { ResponsePrincipal } from './ResponsePrincipal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,7 +26,7 @@ export class ResponseUserGroup extends ResponsePrincipal {
|
|||||||
*/
|
*/
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
permissions: ResponsePermission[];
|
permissions: Permission[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a ResponseUserGroup object from a userGroup.
|
* Creates a ResponseUserGroup object from a userGroup.
|
||||||
@ -36,10 +36,6 @@ export class ResponseUserGroup extends ResponsePrincipal {
|
|||||||
super(group);
|
super(group);
|
||||||
this.name = group.name;
|
this.name = group.name;
|
||||||
this.description = group.description;
|
this.description = group.description;
|
||||||
if (group.permissions) {
|
this.permissions = group.permissions;
|
||||||
for (let permission of group.permissions) {
|
|
||||||
this.permissions.push(permission.toResponse());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user