Merge branch 'dev' into feature/105-addresses
This commit is contained in:
		| @@ -4,7 +4,6 @@ import { | ||||
|   IsString | ||||
| } from "class-validator"; | ||||
| import { ChildEntity, Column } from "typeorm"; | ||||
| import { ResponsePrincipal } from '../responses/ResponsePrincipal'; | ||||
| import { ResponseUserGroup } from '../responses/ResponseUserGroup'; | ||||
| import { Principal } from './Principal'; | ||||
|  | ||||
| @@ -34,7 +33,7 @@ export class UserGroup extends Principal { | ||||
|   /** | ||||
|    * Turns this entity into it's response class. | ||||
|    */ | ||||
|   public toResponse(): ResponsePrincipal { | ||||
|   public toResponse(): ResponseUserGroup { | ||||
|     return new ResponseUserGroup(this); | ||||
|   } | ||||
| } | ||||
| @@ -6,8 +6,8 @@ import { | ||||
|     IsString | ||||
| } from "class-validator"; | ||||
| import { User } from '../entities/User'; | ||||
| import { UserGroup } from '../entities/UserGroup'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
| import { ResponseUserGroup } from './ResponseUserGroup'; | ||||
|  | ||||
| /** | ||||
|  * Defines the user response. | ||||
| @@ -66,7 +66,7 @@ export class ResponseUser extends ResponsePrincipal { | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     groups: UserGroup[]; | ||||
|     groups: ResponseUserGroup[]; | ||||
|  | ||||
|     /** | ||||
|      * The user's permissions. | ||||
| @@ -90,7 +90,11 @@ export class ResponseUser extends ResponsePrincipal { | ||||
|         this.username = user.username; | ||||
|         this.enabled = user.enabled; | ||||
|         this.profilePic = user.profilePic; | ||||
|         this.groups = user.groups; | ||||
|         if (user.groups) { | ||||
|             for (let group of user.groups) { | ||||
|                 this.groups.push(group.toResponse()); | ||||
|             } | ||||
|         } | ||||
|         this.permissions = user.allPermissions; | ||||
|         this.groups.forEach(function (g) { delete g.permissions }); | ||||
|     } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator"; | ||||
| import { Permission } from '../entities/Permission'; | ||||
| import { UserGroup } from '../entities/UserGroup'; | ||||
| import { ResponsePermission } from './ResponsePermission'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
|  | ||||
| /** | ||||
| @@ -26,7 +26,7 @@ export class ResponseUserGroup extends ResponsePrincipal { | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     permissions: Permission[]; | ||||
|     permissions: ResponsePermission[]; | ||||
|  | ||||
|     /** | ||||
|      * Creates a ResponseUserGroup object from a userGroup. | ||||
| @@ -36,6 +36,10 @@ export class ResponseUserGroup extends ResponsePrincipal { | ||||
|         super(group); | ||||
|         this.name = group.name; | ||||
|         this.description = group.description; | ||||
|         this.permissions = group.permissions; | ||||
|         if (group.permissions) { | ||||
|             for (let permission of group.permissions) { | ||||
|                 this.permissions.push(permission.toResponse()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user