From adfc05b387880958eb6f8ba8bd140d52842e8049 Mon Sep 17 00:00:00 2001 From: Dragos Date: Thu, 13 May 2021 13:46:07 +0300 Subject: [PATCH] attempt to create users (currently there's a 500 error) --- app/.vs/app/v16/.suo | Bin 94720 -> 99840 bytes app/.vs/slnx.sqlite | Bin 135168 -> 135168 bytes .../app/security/helpers/security.service.ts | 4 +- app/src/app/security/models/user.ts | 1 + .../policy-editor/policy-editor.component.ts | 4 +- .../user-editor/user-editor.component.html | 49 +++++------------- .../user-editor/user-editor.component.ts | 37 +++++++------ 7 files changed, 38 insertions(+), 57 deletions(-) diff --git a/app/.vs/app/v16/.suo b/app/.vs/app/v16/.suo index 39cecf13a49fbbe9c3111f9d177b7f4dd5a074cb..aa532fb7f1e4dcb5d1da873eaab9f72213127d65 100644 GIT binary patch delta 9253 zcmdT}3sh9sxjuUshT)C81VUg?zy}U8yh#-XK}3Tf(QA!j%7ht|3WzZDDxyOhYmCv9 znJtX<6^hp=HLWTz@)3aTR-+b z|Ji4s{qO&=zkR0ZPp(bd6wNb&d<8*}12=BoyopM10Rp;;@00m7`zn1un)5s62T4;M zZ;&;x4n80&bQgjl`5wT}FP+BMx@^e~!Nu1YKq_vymfAG%EL^J{GV14zwhu7FAuHtB z^7~RsaODor6A`GF0ZL#spaLcWO96U)KCl=F^uR*Yi-2^;_4iRP0Uib>0sg>D;69+rTs%HVkA?v#2UY?!NVT~*z%K|F_X86g zLVnWqkWY>GbCfr`aRCK%kK*%yfTSh;?8YWNoN_0ki}A9kTyI{S0srIAoVa z+f`z%qkLW#n3-r&=~I{ARlLOI1Nf_*X) zK)tWY>q!hjAw|XF5zgN|>c{(z%1!?Q-JDgE2`_Ms=X8fM-Tp?IVhv_^G)dItNoZnX zTS)=-1Rn@09xxF+VPDZnz0G+@QfcHiOvKw8xIA*ENRgxq5l9X1@!0W3`tc(v-pL1uF0?3Q#j*>h9 zZGrz|S-z6ufWnLJC@96e>c$&N8rT#*P*Nxc_9R}v+{BIgaPFs1=l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pXPV}dl}?1?hYjI%c;L@s3${mN)kadYzirCw~JpXb%gzd4zInG%qxDy*3? X*?d_XNP)qV-_5g^ZJ)i2F*Oqas4pC3 delta 68 zcmZozz|pXPV}dke*F+g-#;%PCkxSY5XKfW;xOejYrCu;5|1u>Q(|lPRm|3-;dG@mH KvzIZZW&!}9BOE0F diff --git a/app/src/app/security/helpers/security.service.ts b/app/src/app/security/helpers/security.service.ts index fb0dc73..09d9f42 100644 --- a/app/src/app/security/helpers/security.service.ts +++ b/app/src/app/security/helpers/security.service.ts @@ -34,14 +34,14 @@ export class SecurityService } // ---------------------------------------------------------------------------------------------------------------- - addUser(user: UserRequest): Observable + addUser(user): Observable { return this.httpClient.post(`/api/my/users`, user) .pipe(tap(() => usersCacheBuster$.next())); } // ---------------------------------------------------------------------------------------------------------------- - editUser(userId: string, user: UserRequest): Observable + editUser(userId: string, user): Observable { return this.httpClient.post(`/api/my/users/${userId}`, user) .pipe(tap(() => usersCacheBuster$.next())); diff --git a/app/src/app/security/models/user.ts b/app/src/app/security/models/user.ts index ac979fe..b294612 100644 --- a/app/src/app/security/models/user.ts +++ b/app/src/app/security/models/user.ts @@ -13,6 +13,7 @@ export class UserRequest city: string; state: string; country: string; + password: string; } export class UserResponse extends UserRequest diff --git a/app/src/app/security/policy-editor/policy-editor.component.ts b/app/src/app/security/policy-editor/policy-editor.component.ts index 820390c..17684be 100644 --- a/app/src/app/security/policy-editor/policy-editor.component.ts +++ b/app/src/app/security/policy-editor/policy-editor.component.ts @@ -93,7 +93,7 @@ export class PolicyEditorComponent implements OnInit, OnDestroy // ---------------------------------------------------------------------------------------------------------------- close() { - removeEventListener('document:keydown.escape', this.returnPressed); + removeEventListener('document:keydown.enter', this.returnPressed); this.modalRef.hide(); } @@ -153,6 +153,6 @@ export class PolicyEditorComponent implements OnInit, OnDestroy // -------------------------------------------------------------------------------------------------- ngOnDestroy() { - removeEventListener('document:keydown.escape', this.returnPressed); + removeEventListener('document:keydown.enter', this.returnPressed); } } diff --git a/app/src/app/security/user-editor/user-editor.component.html b/app/src/app/security/user-editor/user-editor.component.html index 51d6040..6148491 100644 --- a/app/src/app/security/user-editor/user-editor.component.html +++ b/app/src/app/security/user-editor/user-editor.component.html @@ -13,7 +13,7 @@
+ [appAutofocus]="true" [appAutofocusDelay]="500">
@@ -25,10 +25,10 @@ -
+
-
@@ -39,6 +39,13 @@
+ +
+ Type in a password + Passwords must be at least 8 characters long + Password must have at least one lower case letter, one capital letter and a number + The two passwords do not match +
Optional fields
@@ -64,43 +71,11 @@ - -
- - + diff --git a/app/src/app/security/user-editor/user-editor.component.ts b/app/src/app/security/user-editor/user-editor.component.ts index 36d5670..c225346 100644 --- a/app/src/app/security/user-editor/user-editor.component.ts +++ b/app/src/app/security/user-editor/user-editor.component.ts @@ -73,7 +73,7 @@ export class UserEditorComponent implements OnInit // -------------------------------------------------------------------------------------------------- private passwordsValidator: ValidatorFn = (group: FormGroup): ValidationErrors | null => { - if (!this.changePassword) + if (!this.changePassword && !!this.user) return null; const password = group.get('password').value; @@ -89,7 +89,7 @@ export class UserEditorComponent implements OnInit const passwordCheck = group.get('passwordCheck').value; - if (passwordCheck && password !== passwordCheck) + if (!passwordCheck || password !== passwordCheck) return { 'passwordMismatch': true }; return null; @@ -104,6 +104,8 @@ export class UserEditorComponent implements OnInit // ---------------------------------------------------------------------------------------------------------------- saveChanges() { + this.working = true; + let observable: Observable; const changes = this.editorForm.getRawValue(); @@ -114,20 +116,18 @@ export class UserEditorComponent implements OnInit } else { - const user = new UserRequest(); - user.login = changes.username; - user.email = changes.email; - user.companyName = changes.companyName; - user.firstName = changes.firstName; - user.lastName = changes.lastName; - user.address = changes.address; - user.postalCode = changes.postalCode; - user.city = changes.city; - user.state = changes.state; - user.country = changes.country; - user.phone = changes.phone; + const user = { + login: changes.username, + email: changes.email, + firstName: changes.firstName, + lastName: changes.lastName, + phone: changes.phone, + password: changes.password + }; - observable = this.securityService.editUser(this.user.id, user); + observable = this.user + ? this.securityService.editUser(this.user.id, user) + : this.securityService.addUser(user); } observable.subscribe(x => @@ -135,7 +135,12 @@ export class UserEditorComponent implements OnInit this.save.next(x as User); this.close(); - }, err => this.toastr.error(err.error.message)); + }, err => + { + this.toastr.error(err.error.message); + + this.working = false; + }); } // ----------------------------------------------------------------------------------------------------------------