Compare commits

...

7 Commits

Author SHA1 Message Date
ae589aeb54 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
2021-01-16 21:15:02 +01:00
1b9d2969eb 🧾New changelog file version [CI SKIP] [skip ci]
All checks were successful
continuous-integration/drone/pr Build is passing
2021-01-16 20:06:31 +00:00
daffbcde72 Merge branch 'dev' of git.odit.services:lfk/backend into dev
Some checks reported errors
continuous-integration/drone/push Build was killed
# Conflicts:
#	CHANGELOG.md
2021-01-16 21:06:12 +01:00
9445c6f21e 🚀Bumped version to v0.1.1 2021-01-16 21:05:43 +01:00
6febb99499 🧾New changelog file version [CI SKIP] [skip ci] 2021-01-16 20:00:06 +00:00
6e6979cfe3 Hotfix: Missing relation bug
All checks were successful
continuous-integration/drone/push Build is passing
2021-01-16 20:59:48 +01:00
de36a24191 🧾New changelog file version [CI SKIP] [skip ci] 2021-01-16 19:32:57 +00:00
6 changed files with 196 additions and 191 deletions

View File

@ -2,15 +2,21 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. 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 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 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) - 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) - 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) - 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) - 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) - 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) - 🧾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) - Moved the me endpoints to /users/me [`f9834b5`](https://git.odit.services/lfk/backend/commit/f9834b5f4d80b11ee5f7773b339dd421341c6e7f)

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/lfk-backend", "name": "@odit/lfk-backend",
"version": "0.1.0", "version": "0.1.1",
"main": "src/app.ts", "main": "src/app.ts",
"repository": "https://git.odit.services/lfk/backend", "repository": "https://git.odit.services/lfk/backend",
"author": { "author": {

View File

@ -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));

View File

@ -1,39 +1,40 @@
import { import {
IsNotEmpty, IsNotEmpty,
IsOptional, IsOptional,
IsString IsString
} from "class-validator"; } from "class-validator";
import { ChildEntity, Column } from "typeorm"; import { ChildEntity, Column } from "typeorm";
import { ResponseUserGroup } from '../responses/ResponseUserGroup'; import { ResponsePrincipal } from '../responses/ResponsePrincipal';
import { Principal } from './Principal'; 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. * Defines the UserGroup entity.
*/ * This entity describes a group of users with a set of permissions.
@ChildEntity() */
export class UserGroup extends Principal { @ChildEntity()
export class UserGroup extends Principal {
/**
* The group's name /**
*/ * The group's name
@Column() */
@IsNotEmpty() @Column()
@IsString() @IsNotEmpty()
name: string; @IsString()
name: string;
/**
* The group's description /**
*/ * The group's description
@Column({ nullable: true }) */
@IsOptional() @Column({ nullable: true })
@IsString() @IsOptional()
description?: string; @IsString()
description?: string;
/**
* Turns this entity into it's response class. /**
*/ * Turns this entity into it's response class.
public toResponse(): ResponseUserGroup { */
return new ResponseUserGroup(this); public toResponse(): ResponsePrincipal {
} return new ResponseUserGroup(this);
}
} }

View File

@ -1,101 +1,99 @@
import { import {
IsArray, IsArray,
IsBoolean, IsBoolean,
IsOptional, IsOptional,
IsString IsString
} from "class-validator"; } from "class-validator";
import { User } from '../entities/User'; import { User } from '../entities/User';
import { ResponsePrincipal } from './ResponsePrincipal'; import { UserGroup } from '../entities/UserGroup';
import { ResponseUserGroup } from './ResponseUserGroup'; import { ResponsePrincipal } from './ResponsePrincipal';
/** /**
* Defines the user response. * Defines the user response.
*/ */
export class ResponseUser extends ResponsePrincipal { export class ResponseUser extends ResponsePrincipal {
/** /**
* The user's first name. * The user's first name.
*/ */
@IsString() @IsString()
firstname: string; firstname: string;
/** /**
* The user's middle name. * The user's middle name.
*/ */
@IsString() @IsString()
middlename?: string; middlename?: string;
/** /**
* The user's last name. * The user's last name.
*/ */
@IsString() @IsString()
lastname: string; lastname: string;
/** /**
* The user's phone number. * The user's phone number.
*/ */
@IsString() @IsString()
phone?: string; phone?: string;
/** /**
* The user's e-mail address. * The user's e-mail address.
*/ */
@IsString() @IsString()
email?: string; email?: string;
/** /**
* The user's username. * The user's username.
*/ */
@IsString() @IsString()
username?: string; username?: string;
/** /**
* Is user enabled? * Is user enabled?
*/ */
@IsBoolean() @IsBoolean()
enabled: boolean = true; enabled: boolean = true;
/** /**
* The user's profile pic (or rather a url pointing to it). * The user's profile pic (or rather a url pointing to it).
*/ */
@IsString() @IsString()
profilePic: string; profilePic: string;
/** /**
* The groups that the user is a part of. * The groups that the user is a part of.
*/ */
@IsArray() @IsArray()
@IsOptional() @IsOptional()
groups: ResponseUserGroup[]; groups: UserGroup[];
/** /**
* The user's permissions. * The user's permissions.
* Directly granted or inherited converted to their string form and deduplicated. * Directly granted or inherited converted to their string form and deduplicated.
*/ */
@IsArray() @IsArray()
@IsOptional() @IsOptional()
permissions: string[]; permissions: string[];
/** /**
* Creates a ResponseUser object from a user. * Creates a ResponseUser object from a user.
* @param user The user the response shall be build for. * @param user The user the response shall be build for.
*/ */
public constructor(user: User) { public constructor(user: User) {
super(user); super(user);
this.firstname = user.firstname; this.firstname = user.firstname;
this.middlename = user.middlename; this.middlename = user.middlename;
this.lastname = user.lastname; this.lastname = user.lastname;
this.phone = user.phone; this.phone = user.phone;
this.email = user.email; this.email = user.email;
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.permissions = user.allPermissions;
this.groups.push(group.toResponse()); if (this.groups) {
} this.groups.forEach(function (g) { delete g.permissions });
} }
this.permissions = user.allPermissions; }
this.groups.forEach(function (g) { delete g.permissions }); }
}
}

View File

@ -1,45 +1,41 @@
import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator"; import { IsArray, IsNotEmpty, IsOptional, IsString } from "class-validator";
import { UserGroup } from '../entities/UserGroup'; import { Permission } from '../entities/Permission';
import { ResponsePermission } from './ResponsePermission'; import { UserGroup } from '../entities/UserGroup';
import { ResponsePrincipal } from './ResponsePrincipal'; import { ResponsePrincipal } from './ResponsePrincipal';
/** /**
* Defines the userGroup response. * Defines the userGroup response.
*/ */
export class ResponseUserGroup extends ResponsePrincipal { export class ResponseUserGroup extends ResponsePrincipal {
/** /**
* The userGroup's name. * The userGroup's name.
*/ */
@IsNotEmpty() @IsNotEmpty()
@IsString() @IsString()
name: string; name: string;
/** /**
* The userGroup's description. * The userGroup's description.
*/ */
@IsOptional() @IsOptional()
@IsString() @IsString()
description?: string; description?: string;
/** /**
* The userGroup's permissions. * The userGroup's permissions.
*/ */
@IsArray() @IsArray()
@IsOptional() @IsOptional()
permissions: ResponsePermission[]; permissions: Permission[];
/** /**
* Creates a ResponseUserGroup object from a userGroup. * Creates a ResponseUserGroup object from a userGroup.
* @param group The userGroup the response shall be build for. * @param group The userGroup the response shall be build for.
*/ */
public constructor(group: UserGroup) { public constructor(group: UserGroup) {
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()); }
}
}
}
}