Merge branch 'dev' into feature/105-addresses
# Conflicts: # src/errors/AddressErrors.ts # src/models/actions/create/CreateAddress.ts # src/models/actions/create/CreateDonor.ts # src/models/actions/create/CreateGroupContact.ts # src/models/actions/create/CreateParticipant.ts # src/models/actions/create/CreateRunner.ts # src/models/actions/create/CreateRunnerOrganisation.ts # src/models/actions/update/UpdateDonor.ts # src/models/actions/update/UpdateRunner.ts # src/models/actions/update/UpdateRunnerOrganisation.ts # src/models/entities/Address.ts # src/models/entities/IAddressUser.ts # src/models/entities/RunnerOrganisation.ts # src/models/responses/ResponseParticipant.ts # src/tests/donors/donor_add.spec.ts # src/tests/donors/donor_update.spec.ts # src/tests/runnerOrgs/org_add.spec.ts # src/tests/runnerOrgs/org_delete.spec.ts # src/tests/runnerOrgs/org_update.spec.ts # src/tests/runnerTeams/team_update.spec.ts # src/tests/runners/runner_update.spec.ts
This commit is contained in:
		
							
								
								
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -2,15 +2,21 @@ | ||||
|  | ||||
| All notable changes to this project will be documented in this file. Dates are displayed in UTC. | ||||
|  | ||||
| #### [v0.1.0](https://git.odit.services/lfk/backend/compare/v0.1.0...v0.1.0) | ||||
| #### [v0.1.1](https://git.odit.services/lfk/backend/compare/v0.1.0...v0.1.1) | ||||
|  | ||||
| - Merge pull request 'User self-management feature/100-me_endpoints' (#103) from feature/100-me_endpoints into dev [`a6c7d54`](https://git.odit.services/lfk/backend/commit/a6c7d54fe72ffe23add926afa0be150a7a370099) | ||||
| - 🚀Bumped version to v0.1.1 [`9445c6f`](https://git.odit.services/lfk/backend/commit/9445c6f21e376329b9200664a44a94ba1f1dd463) | ||||
| - Implemented the /me controller that allows a user to get and update themselves [`8ef5f90`](https://git.odit.services/lfk/backend/commit/8ef5f90abda97a73d5c5a7767a144ac3fb5288c1) | ||||
| - Implemented a baisc user checker/getter [`f1db883`](https://git.odit.services/lfk/backend/commit/f1db8836092269966a7f54e69b1f20c171e81b21) | ||||
| - Implemented getting own permissions [`4f6e816`](https://git.odit.services/lfk/backend/commit/4f6e81677c81c852e735407295c634b43b317479) | ||||
| - Hotfix: Missing relation bug [`6e6979c`](https://git.odit.services/lfk/backend/commit/6e6979cfe3660056cff6b9eabc194852234ac0a6) | ||||
| - Hotfix: Missing relation bug [`b167ba0`](https://git.odit.services/lfk/backend/commit/b167ba07f79709a2c3b33c5546c52659c42863f3) | ||||
| - automaticly merge main into dev after building a latest image [`02efb9a`](https://git.odit.services/lfk/backend/commit/02efb9a8e55831ecce4109e17b2f07a56e491fd5) | ||||
| - User deletion now requires confirmation [`6b7ecd3`](https://git.odit.services/lfk/backend/commit/6b7ecd3044c45b2eed46ee5010bed4dab4f02df9) | ||||
| - 🧾New changelog file version [CI SKIP] [skip ci] [`3766899`](https://git.odit.services/lfk/backend/commit/3766899c8393545a89986a98dafd542edc4a1d39) | ||||
| - Created barebones file for the userchecker [`e586a11`](https://git.odit.services/lfk/backend/commit/e586a11e2ad42af9c9bb5d2a47f48e3306fe49b2) | ||||
| - 🧾New changelog file version [CI SKIP] [skip ci] [`6febb99`](https://git.odit.services/lfk/backend/commit/6febb994990b4cab7ee54b0368f74dd95664bfdf) | ||||
| - 🧾New changelog file version [CI SKIP] [skip ci] [`de36a24`](https://git.odit.services/lfk/backend/commit/de36a24191a8cdc4ff6b23637ea9f91109b59bbb) | ||||
| - Merge pull request 'User self-management feature/100-me_endpoints' (#103) from feature/100-me_endpoints into dev [`a6c7d54`](https://git.odit.services/lfk/backend/commit/a6c7d54fe72ffe23add926afa0be150a7a370099) | ||||
| - Updated descriptions and responses [`fc7b8f4`](https://git.odit.services/lfk/backend/commit/fc7b8f4c16cef0e72b04f096d5a17d4144b5feb7) | ||||
| - 🧾New changelog file version [CI SKIP] [skip ci] [`50b893f`](https://git.odit.services/lfk/backend/commit/50b893f5370902ccc40f8bb45ed160103400f529) | ||||
| - Moved the me endpoints to /users/me [`f9834b5`](https://git.odit.services/lfk/backend/commit/f9834b5f4d80b11ee5f7773b339dd421341c6e7f) | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@odit/lfk-backend", | ||||
|   "version": "0.1.0", | ||||
|   "version": "0.1.1", | ||||
|   "main": "src/app.ts", | ||||
|   "repository": "https://git.odit.services/lfk/backend", | ||||
|   "author": { | ||||
|   | ||||
| @@ -138,8 +138,10 @@ export class User extends Principal { | ||||
|  | ||||
|     if (!this.groups) { return returnPermissions; } | ||||
|     for (let group of this.groups) { | ||||
|       for (let permission of group.permissions) { | ||||
|         returnPermissions.push(permission); | ||||
|       if (group.permissions) { | ||||
|         for (let permission of group.permissions) { | ||||
|           returnPermissions.push(permission); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     return returnPermissions; | ||||
| @@ -159,8 +161,10 @@ export class User extends Principal { | ||||
|  | ||||
|     if (!this.groups) { return returnPermissions; } | ||||
|     for (let group of this.groups) { | ||||
|       for (let permission of group.permissions) { | ||||
|         returnPermissions.push(permission.toString()); | ||||
|       if (group.permissions) { | ||||
|         for (let permission of group.permissions) { | ||||
|           returnPermissions.push(permission.toString()); | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|     return Array.from(new Set(returnPermissions)); | ||||
|   | ||||
| @@ -1,39 +1,40 @@ | ||||
| import { | ||||
|   IsNotEmpty, | ||||
|   IsOptional, | ||||
|   IsString | ||||
| } from "class-validator"; | ||||
| import { ChildEntity, Column } from "typeorm"; | ||||
| import { ResponseUserGroup } from '../responses/ResponseUserGroup'; | ||||
| import { Principal } from './Principal'; | ||||
|  | ||||
| /** | ||||
|  * Defines the UserGroup entity. | ||||
|  * This entity describes a group of users with a set of permissions. | ||||
| */ | ||||
| @ChildEntity() | ||||
| export class UserGroup extends Principal { | ||||
|  | ||||
|   /** | ||||
|    * The group's name | ||||
|    */ | ||||
|   @Column() | ||||
|   @IsNotEmpty() | ||||
|   @IsString() | ||||
|   name: string; | ||||
|  | ||||
|   /** | ||||
|    * The group's description | ||||
|    */ | ||||
|   @Column({ nullable: true }) | ||||
|   @IsOptional() | ||||
|   @IsString() | ||||
|   description?: string; | ||||
|  | ||||
|   /** | ||||
|    * Turns this entity into it's response class. | ||||
|    */ | ||||
|   public toResponse(): ResponseUserGroup { | ||||
|     return new ResponseUserGroup(this); | ||||
|   } | ||||
| import { | ||||
|   IsNotEmpty, | ||||
|   IsOptional, | ||||
|   IsString | ||||
| } from "class-validator"; | ||||
| import { ChildEntity, Column } from "typeorm"; | ||||
| import { ResponsePrincipal } from '../responses/ResponsePrincipal'; | ||||
| import { ResponseUserGroup } from '../responses/ResponseUserGroup'; | ||||
| import { Principal } from './Principal'; | ||||
|  | ||||
| /** | ||||
|  * Defines the UserGroup entity. | ||||
|  * This entity describes a group of users with a set of permissions. | ||||
| */ | ||||
| @ChildEntity() | ||||
| export class UserGroup extends Principal { | ||||
|  | ||||
|   /** | ||||
|    * The group's name | ||||
|    */ | ||||
|   @Column() | ||||
|   @IsNotEmpty() | ||||
|   @IsString() | ||||
|   name: string; | ||||
|  | ||||
|   /** | ||||
|    * The group's description | ||||
|    */ | ||||
|   @Column({ nullable: true }) | ||||
|   @IsOptional() | ||||
|   @IsString() | ||||
|   description?: string; | ||||
|  | ||||
|   /** | ||||
|    * Turns this entity into it's response class. | ||||
|    */ | ||||
|   public toResponse(): ResponsePrincipal { | ||||
|     return new ResponseUserGroup(this); | ||||
|   } | ||||
| } | ||||
| @@ -1,101 +1,99 @@ | ||||
| import { | ||||
|     IsArray, | ||||
|     IsBoolean, | ||||
|  | ||||
|     IsOptional, | ||||
|     IsString | ||||
| } from "class-validator"; | ||||
| import { User } from '../entities/User'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
| import { ResponseUserGroup } from './ResponseUserGroup'; | ||||
|  | ||||
| /** | ||||
|  * Defines the user response. | ||||
| */ | ||||
| export class ResponseUser extends ResponsePrincipal { | ||||
|     /** | ||||
|      * The user's first name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     firstname: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's middle name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     middlename?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's last name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     lastname: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's phone number. | ||||
|      */ | ||||
|     @IsString() | ||||
|     phone?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's e-mail address. | ||||
|      */ | ||||
|     @IsString() | ||||
|     email?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's username. | ||||
|      */ | ||||
|     @IsString() | ||||
|     username?: string; | ||||
|  | ||||
|     /** | ||||
|     * Is user enabled? | ||||
|     */ | ||||
|     @IsBoolean() | ||||
|     enabled: boolean = true; | ||||
|  | ||||
|     /** | ||||
|     * The user's profile pic (or rather a url pointing to it). | ||||
|     */ | ||||
|     @IsString() | ||||
|     profilePic: string; | ||||
|  | ||||
|     /** | ||||
|      * The groups that the user is a part of. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     groups: ResponseUserGroup[]; | ||||
|  | ||||
|     /** | ||||
|      * The user's permissions. | ||||
|      * Directly granted or inherited converted to their string form and deduplicated. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     permissions: string[]; | ||||
|  | ||||
|     /** | ||||
|      * Creates a ResponseUser object from a user. | ||||
|      * @param user The user the response shall be build for. | ||||
|      */ | ||||
|     public constructor(user: User) { | ||||
|         super(user); | ||||
|         this.firstname = user.firstname; | ||||
|         this.middlename = user.middlename; | ||||
|         this.lastname = user.lastname; | ||||
|         this.phone = user.phone; | ||||
|         this.email = user.email; | ||||
|         this.username = user.username; | ||||
|         this.enabled = user.enabled; | ||||
|         this.profilePic = user.profilePic; | ||||
|         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 }); | ||||
|     } | ||||
| } | ||||
| import { | ||||
|     IsArray, | ||||
|     IsBoolean, | ||||
|  | ||||
|     IsOptional, | ||||
|     IsString | ||||
| } from "class-validator"; | ||||
| import { User } from '../entities/User'; | ||||
| import { UserGroup } from '../entities/UserGroup'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
|  | ||||
| /** | ||||
|  * Defines the user response. | ||||
| */ | ||||
| export class ResponseUser extends ResponsePrincipal { | ||||
|     /** | ||||
|      * The user's first name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     firstname: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's middle name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     middlename?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's last name. | ||||
|      */ | ||||
|     @IsString() | ||||
|     lastname: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's phone number. | ||||
|      */ | ||||
|     @IsString() | ||||
|     phone?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's e-mail address. | ||||
|      */ | ||||
|     @IsString() | ||||
|     email?: string; | ||||
|  | ||||
|     /** | ||||
|      * The user's username. | ||||
|      */ | ||||
|     @IsString() | ||||
|     username?: string; | ||||
|  | ||||
|     /** | ||||
|     * Is user enabled? | ||||
|     */ | ||||
|     @IsBoolean() | ||||
|     enabled: boolean = true; | ||||
|  | ||||
|     /** | ||||
|     * The user's profile pic (or rather a url pointing to it). | ||||
|     */ | ||||
|     @IsString() | ||||
|     profilePic: string; | ||||
|  | ||||
|     /** | ||||
|      * The groups that the user is a part of. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     groups: UserGroup[]; | ||||
|  | ||||
|     /** | ||||
|      * The user's permissions. | ||||
|      * Directly granted or inherited converted to their string form and deduplicated. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     permissions: string[]; | ||||
|  | ||||
|     /** | ||||
|      * Creates a ResponseUser object from a user. | ||||
|      * @param user The user the response shall be build for. | ||||
|      */ | ||||
|     public constructor(user: User) { | ||||
|         super(user); | ||||
|         this.firstname = user.firstname; | ||||
|         this.middlename = user.middlename; | ||||
|         this.lastname = user.lastname; | ||||
|         this.phone = user.phone; | ||||
|         this.email = user.email; | ||||
|         this.username = user.username; | ||||
|         this.enabled = user.enabled; | ||||
|         this.profilePic = user.profilePic; | ||||
|         this.groups = user.groups; | ||||
|         this.permissions = user.allPermissions; | ||||
|         if (this.groups) { | ||||
|             this.groups.forEach(function (g) { delete g.permissions }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,45 +1,41 @@ | ||||
| import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator"; | ||||
| import { UserGroup } from '../entities/UserGroup'; | ||||
| import { ResponsePermission } from './ResponsePermission'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
|  | ||||
| /** | ||||
|  * Defines the userGroup response. | ||||
| */ | ||||
| export class ResponseUserGroup extends ResponsePrincipal { | ||||
|     /** | ||||
|      * The userGroup's name. | ||||
|      */ | ||||
|     @IsNotEmpty() | ||||
|     @IsString() | ||||
|     name: string; | ||||
|  | ||||
|     /** | ||||
|      * The userGroup's description. | ||||
|      */ | ||||
|     @IsOptional() | ||||
|     @IsString() | ||||
|     description?: string; | ||||
|  | ||||
|     /** | ||||
|      * The userGroup's permissions. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     permissions: ResponsePermission[]; | ||||
|  | ||||
|     /** | ||||
|      * Creates a ResponseUserGroup object from a userGroup. | ||||
|      * @param group The userGroup the response shall be build for. | ||||
|      */ | ||||
|     public constructor(group: UserGroup) { | ||||
|         super(group); | ||||
|         this.name = group.name; | ||||
|         this.description = group.description; | ||||
|         if (group.permissions) { | ||||
|             for (let permission of group.permissions) { | ||||
|                 this.permissions.push(permission.toResponse()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator"; | ||||
| import { Permission } from '../entities/Permission'; | ||||
| import { UserGroup } from '../entities/UserGroup'; | ||||
| import { ResponsePrincipal } from './ResponsePrincipal'; | ||||
|  | ||||
| /** | ||||
|  * Defines the userGroup response. | ||||
| */ | ||||
| export class ResponseUserGroup extends ResponsePrincipal { | ||||
|     /** | ||||
|      * The userGroup's name. | ||||
|      */ | ||||
|     @IsNotEmpty() | ||||
|     @IsString() | ||||
|     name: string; | ||||
|  | ||||
|     /** | ||||
|      * The userGroup's description. | ||||
|      */ | ||||
|     @IsOptional() | ||||
|     @IsString() | ||||
|     description?: string; | ||||
|  | ||||
|     /** | ||||
|      * The userGroup's permissions. | ||||
|      */ | ||||
|     @IsArray() | ||||
|     @IsOptional() | ||||
|     permissions: Permission[]; | ||||
|  | ||||
|     /** | ||||
|      * Creates a ResponseUserGroup object from a userGroup. | ||||
|      * @param group The userGroup the response shall be build for. | ||||
|      */ | ||||
|     public constructor(group: UserGroup) { | ||||
|         super(group); | ||||
|         this.name = group.name; | ||||
|         this.description = group.description; | ||||
|         this.permissions = group.permissions; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user