From 3c1f017e3aba49e4cb29c893189fe3c0b9ac5c2e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 10 Nov 2022 20:26:29 +0100 Subject: [PATCH 1/2] Fixed admins cannot assign users to admins #88 --- kdb-bot/src/bot_api/json_processor.py | 4 ++++ kdb-bot/src/bot_api/model/auth_user_dto.py | 2 +- kdb-bot/src/bot_api/model/update_auth_user_dto.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kdb-bot/src/bot_api/json_processor.py b/kdb-bot/src/bot_api/json_processor.py index a0ea0ac1..ede53d2c 100644 --- a/kdb-bot/src/bot_api/json_processor.py +++ b/kdb-bot/src/bot_api/json_processor.py @@ -1,3 +1,4 @@ +import enum from inspect import signature, Parameter from cpl_core.utils import String @@ -28,6 +29,9 @@ class JSONProcessor: if isinstance(value, dict): value = JSONProcessor.process(parameter.annotation, value) + if issubclass(parameter.annotation, enum.Enum): + value = parameter.annotation(value) + args.append(value) elif parameter.default != Parameter.empty: diff --git a/kdb-bot/src/bot_api/model/auth_user_dto.py b/kdb-bot/src/bot_api/model/auth_user_dto.py index 15efc559..347df8ad 100644 --- a/kdb-bot/src/bot_api/model/auth_user_dto.py +++ b/kdb-bot/src/bot_api/model/auth_user_dto.py @@ -85,7 +85,7 @@ class AuthUserDTO(DtoABC): self._email = values['email'] self._password = values['password'] self._is_confirmed = values['isConfirmed'] - self._auth_role = values['authRole'] + self._auth_role = AuthRoleEnum(values['authRole']) def to_dict(self) -> dict: return { diff --git a/kdb-bot/src/bot_api/model/update_auth_user_dto.py b/kdb-bot/src/bot_api/model/update_auth_user_dto.py index 254c0c72..ac71e033 100644 --- a/kdb-bot/src/bot_api/model/update_auth_user_dto.py +++ b/kdb-bot/src/bot_api/model/update_auth_user_dto.py @@ -33,8 +33,8 @@ class UpdateAuthUserDTO(DtoABC): return self._change_password def from_dict(self, values: dict): - self._auth_user = values['authUser'] - self._new_auth_user = values['newAuthUser'] + self._auth_user = AuthUserDTO().from_dict(values['authUser']) + self._new_auth_user = AuthUserDTO().from_dict(values['newAuthUser']) self._change_password = False if 'changePassword' not in values else bool(values['changePassword']) def to_dict(self) -> dict: From 87435614db709b23544ab0033ef17ed6a7342133 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 14 Nov 2022 20:10:44 +0100 Subject: [PATCH 2/2] Fixed angular setup for windoof and linux --- kdb-web/package.json | 5 ++--- kdb-web/tsconfig.json | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/kdb-web/package.json b/kdb-web/package.json index 3e87f4ec..c6c72b80 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,9 +1,9 @@ { "name": "kdb-web", - "version": "0.3.dev70", + "version": "0.3.0", "scripts": { "ng": "ng", - "update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts", + "update-version": "ts-node-esm update-version.ts", "prestart": "npm run update-version", "start": "ng serve", "prebuild": "npm run update-version", @@ -48,7 +48,6 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.0.0", "karma-jasmine-html-reporter": "~1.7.0", - "ts-node": "~8.3.0", "typescript": "~4.7.2" } } \ No newline at end of file diff --git a/kdb-web/tsconfig.json b/kdb-web/tsconfig.json index ff06eae1..e541544c 100644 --- a/kdb-web/tsconfig.json +++ b/kdb-web/tsconfig.json @@ -1,5 +1,10 @@ /* To learn more about this file see: https://angular.io/config/tsconfig. */ { + "ts-node": { + "compilerOptions": { + "module": "CommonJS" + } + }, "compileOnSave": false, "compilerOptions": { "baseUrl": "./",