diff --git a/app/.vs/app/v16/.suo b/app/.vs/app/v16/.suo index 39cecf1..aa532fb 100644 Binary files a/app/.vs/app/v16/.suo and b/app/.vs/app/v16/.suo differ diff --git a/app/.vs/slnx.sqlite b/app/.vs/slnx.sqlite index 20a45cd..6684331 100644 Binary files a/app/.vs/slnx.sqlite and b/app/.vs/slnx.sqlite differ 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; + }); } // ----------------------------------------------------------------------------------------------------------------