Skip to content

Commit fefd989

Browse files
Copilotrenemadsen
andcommitted
Update password strength configuration per requirements: disable special chars, min 8 chars
Co-authored-by: renemadsen <[email protected]>
1 parent ddfc8e7 commit fefd989

File tree

9 files changed

+110
-142
lines changed

9 files changed

+110
-142
lines changed

INTEGRATION_STEPS.md

Lines changed: 53 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,55 @@
11
# Angular Material Extensions Password Strength Integration
22

3-
## Completed Steps
4-
5-
1.**Added package dependency** - Updated `package.json` with `@angular-material-extensions/password-strength`
6-
2.**Updated module imports** - Added import statements (commented) in:
7-
- `account-management.module.ts`
8-
- `auth.module.ts`
9-
3.**Updated component templates** - Added password strength meter HTML (commented) in:
10-
- `user-set-password.component.html`
11-
- `change-password.component.html`
12-
- `restore-password-confirmation.component.html`
13-
4.**Updated component TypeScript files** - Added password strength handling methods (commented) in all components
14-
15-
## Remaining Steps
16-
17-
To complete the integration once network issues are resolved:
18-
19-
### 1. Install the Package
20-
```bash
21-
cd eform-client
22-
npm install @angular-material-extensions/[email protected] --save --force
23-
```
24-
25-
### 2. Uncomment Module Imports
26-
In `src/app/modules/account-management/account-management.module.ts`:
27-
```typescript
28-
// Uncomment this line:
29-
import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
30-
31-
// And add to imports array:
32-
MatPasswordStrengthModule,
33-
```
34-
35-
In `src/app/modules/auth/auth.module.ts`:
36-
```typescript
37-
// Uncomment this line:
38-
import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
39-
40-
// And add to imports array:
41-
MatPasswordStrengthModule,
42-
```
43-
44-
### 3. Uncomment HTML Components
45-
In each of the three component HTML files, uncomment the `<mat-password-strength>` elements.
46-
47-
### 4. Uncomment TypeScript Methods
48-
In each of the three component TypeScript files, uncomment the `onPasswordStrengthChanged` methods.
49-
50-
## Features Implemented
51-
52-
- **Password strength visualization**: Real-time strength meter
53-
- **Configurable rules**: Length, lowercase, uppercase, digits, special characters
54-
- **Strength scoring**: 0-100 scale with event handling
55-
- **Form validation integration**: Optional weak password validation
56-
- **Responsive design**: Integrates seamlessly with Material Design
57-
58-
## Configuration Options
59-
60-
The password strength component supports these configuration options:
61-
- `enableLengthRule`: Enforce minimum length
62-
- `enableLowerCaseLetterRule`: Require lowercase letters
63-
- `enableUpperCaseLetterRule`: Require uppercase letters
64-
- `enableDigitRule`: Require numbers
65-
- `enableSpecialCharRule`: Require special characters
66-
- `min`: Minimum password length (6)
67-
- `max`: Maximum password length (50)
68-
69-
## Testing
70-
71-
After uncommenting and installing:
72-
1. Run `ng build` to ensure no compilation errors
73-
2. Test each password field for visual feedback
74-
3. Verify strength scoring works correctly
75-
4. Test form validation integration
3+
## ✅ Integration Complete
4+
5+
The password strength meter has been successfully integrated with the following configuration:
6+
7+
### Configuration Applied
8+
- `enableLengthRule`: true
9+
- `enableLowerCaseLetterRule`: true
10+
- `enableUpperCaseLetterRule`: true
11+
- `enableDigitRule`: true
12+
- `enableSpecialCharRule`: false *(disabled per requirements)*
13+
- `min`: 8 *(minimum password length)*
14+
- `max`: 50
15+
16+
### Components Updated
17+
1.**User Set Password Modal** (`user-set-password.component.*`) - Admin password setting
18+
2.**Change Password** (`change-password.component.*`) - User profile password change
19+
3.**Restore Password Confirmation** (`restore-password-confirmation.component.*`) - Password reset flow
20+
21+
### Implementation Details
22+
- ✅ Package installed: `@angular-material-extensions/[email protected]`
23+
- ✅ Module imports activated in `account-management.module.ts` and `auth.module.ts`
24+
- ✅ HTML templates updated with password strength meters
25+
- ✅ TypeScript methods implemented for strength tracking
26+
- ✅ Form validation updated to require minimum 8 characters
27+
- ✅ Special character requirements disabled as requested
28+
29+
### Features Implemented
30+
- **Real-time password strength visualization**: Color-coded strength indicators
31+
- **Configurable validation rules**: Length, lowercase, uppercase, digits (special chars disabled)
32+
- **Strength scoring**: 0-100 scale with event handling
33+
- **Form validation integration**: Weak password validation (< 40 strength)
34+
- **Material Design integration**: Seamless visual integration
35+
36+
## Testing Recommendations
37+
1. Test each password field for visual feedback
38+
2. Verify strength scoring works correctly (0-100 scale)
39+
3. Test form validation integration with weak passwords
40+
4. Ensure all password requirements are enforced except special characters
41+
42+
## Example Usage
43+
```html
44+
<mat-password-strength
45+
[password]="form.get('newPassword')?.value || ''"
46+
[enableLengthRule]="true"
47+
[enableLowerCaseLetterRule]="true"
48+
[enableUpperCaseLetterRule]="true"
49+
[enableDigitRule]="true"
50+
[enableSpecialCharRule]="false"
51+
[min]="8"
52+
[max]="50"
53+
(onStrengthChanged)="onPasswordStrengthChanged($event)">
54+
</mat-password-strength>
55+
```

eform-client/src/app/modules/account-management/account-management.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {MatDialogModule} from '@angular/material/dialog';
2323
import {MatInputModule} from '@angular/material/input';
2424
import {MatIconModule} from '@angular/material/icon';
2525
import {FileUploadModule} from "ng2-file-upload";
26-
// import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
26+
import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
2727

2828
@NgModule({
2929
imports: [
@@ -45,7 +45,7 @@ import {FileUploadModule} from "ng2-file-upload";
4545
MatInputModule,
4646
MatIconModule,
4747
FileUploadModule,
48-
// MatPasswordStrengthModule,
48+
MatPasswordStrengthModule,
4949
],
5050
declarations: [
5151
ChangePasswordComponent,

eform-client/src/app/modules/account-management/components/profile/change-password/change-password.component.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,17 @@
3737
</mat-form-field>
3838

3939
<!-- Password Strength Meter -->
40-
<!-- TODO: Uncomment once @angular-material-extensions/password-strength is installed -->
41-
<!--
4240
<mat-password-strength
4341
[password]="changePasswordForm.get('newPassword')?.value || ''"
4442
[enableLengthRule]="true"
4543
[enableLowerCaseLetterRule]="true"
4644
[enableUpperCaseLetterRule]="true"
4745
[enableDigitRule]="true"
48-
[enableSpecialCharRule]="true"
49-
[min]="6"
46+
[enableSpecialCharRule]="false"
47+
[min]="8"
5048
[max]="50"
5149
(onStrengthChanged)="onPasswordStrengthChanged($event)">
5250
</mat-password-strength>
53-
-->
5451

5552
<mat-form-field>
5653
<mat-label>{{ 'New password confirmation' | translate }}</mat-label>

eform-client/src/app/modules/account-management/components/profile/change-password/change-password.component.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export class ChangePasswordComponent implements OnInit {
1515
passwordStrength = 0; // Track password strength score
1616
constructor(private authService: AuthService, private fb: FormBuilder) {
1717
this.changePasswordForm = this.fb.group({
18-
oldPassword: ['', [Validators.required, Validators.min(8)]],
19-
newPassword: ['', [Validators.required, Validators.min(8)]],
20-
confirmPassword: ['', [Validators.required, Validators.min(8)/*, this.checkPasswords*/]]
18+
oldPassword: ['', [Validators.required, Validators.minLength(8)]],
19+
newPassword: ['', [Validators.required, Validators.minLength(8)]],
20+
confirmPassword: ['', [Validators.required, Validators.minLength(8)/*, this.checkPasswords*/]]
2121
});
2222
}
2323

@@ -38,20 +38,19 @@ export class ChangePasswordComponent implements OnInit {
3838
);
3939
}
4040

41-
// TODO: Uncomment once @angular-material-extensions/password-strength is installed
42-
// onPasswordStrengthChanged(strength: number): void {
43-
// this.passwordStrength = strength;
44-
// // Optionally add additional validation based on strength
45-
// const passwordControl = this.changePasswordForm.get('newPassword');
46-
// if (passwordControl && strength < 40) {
47-
// passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
48-
// } else if (passwordControl && passwordControl.hasError('weakPassword')) {
49-
// delete passwordControl.errors.weakPassword;
50-
// if (Object.keys(passwordControl.errors).length === 0) {
51-
// passwordControl.setErrors(null);
52-
// }
53-
// }
54-
// }
41+
onPasswordStrengthChanged(strength: number): void {
42+
this.passwordStrength = strength;
43+
// Optionally add additional validation based on strength
44+
const passwordControl = this.changePasswordForm.get('newPassword');
45+
if (passwordControl && strength < 40) {
46+
passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
47+
} else if (passwordControl && passwordControl.hasError('weakPassword')) {
48+
delete passwordControl.errors.weakPassword;
49+
if (Object.keys(passwordControl.errors).length === 0) {
50+
passwordControl.setErrors(null);
51+
}
52+
}
53+
}
5554

5655
/* checkPasswords(group: FormGroup) {
5756
let pass = group.get('newPassword').value;

eform-client/src/app/modules/account-management/components/users/user-set-password-modal/user-set-password.component.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,17 @@ <h3 mat-dialog-title>{{'Set user password' | translate}}</h3>
3939
</mat-form-field>
4040

4141
<!-- Password Strength Meter -->
42-
<!-- TODO: Uncomment once @angular-material-extensions/password-strength is installed -->
43-
<!--
4442
<mat-password-strength
4543
[password]="setPasswordForm.get('newPassword')?.value || ''"
4644
[enableLengthRule]="true"
4745
[enableLowerCaseLetterRule]="true"
4846
[enableUpperCaseLetterRule]="true"
4947
[enableDigitRule]="true"
50-
[enableSpecialCharRule]="true"
51-
[min]="6"
48+
[enableSpecialCharRule]="false"
49+
[min]="8"
5250
[max]="50"
5351
(onStrengthChanged)="onPasswordStrengthChanged($event)">
5452
</mat-password-strength>
55-
-->
5653

5754
<mat-form-field>
5855
<mat-label>{{ 'New password confirmation' | translate }}</mat-label>

eform-client/src/app/modules/account-management/components/users/user-set-password-modal/user-set-password.component.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export class UserSetPasswordComponent implements OnInit {
2222
public dialogRef: MatDialogRef<UserSetPasswordComponent>,
2323
@Inject(MAT_DIALOG_DATA) public selectedUser: UserInfoModel = new UserInfoModel()) {
2424
this.setPasswordForm = this.fb.group({
25-
newPassword: ['', [Validators.minLength(6)]],
26-
confirmPassword: ['', [Validators.minLength(6)]]
25+
newPassword: ['', [Validators.minLength(8)]],
26+
confirmPassword: ['', [Validators.minLength(8)]]
2727
});
2828
}
2929

@@ -57,18 +57,17 @@ export class UserSetPasswordComponent implements OnInit {
5757
this.confirmPasswordVisible = !this.confirmPasswordVisible;
5858
}
5959

60-
// TODO: Uncomment once @angular-material-extensions/password-strength is installed
61-
// onPasswordStrengthChanged(strength: number): void {
62-
// this.passwordStrength = strength;
63-
// // Optionally add additional validation based on strength
64-
// const passwordControl = this.setPasswordForm.get('newPassword');
65-
// if (passwordControl && strength < 40) {
66-
// passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
67-
// } else if (passwordControl && passwordControl.hasError('weakPassword')) {
68-
// delete passwordControl.errors.weakPassword;
69-
// if (Object.keys(passwordControl.errors).length === 0) {
70-
// passwordControl.setErrors(null);
71-
// }
72-
// }
73-
// }
60+
onPasswordStrengthChanged(strength: number): void {
61+
this.passwordStrength = strength;
62+
// Optionally add additional validation based on strength
63+
const passwordControl = this.setPasswordForm.get('newPassword');
64+
if (passwordControl && strength < 40) {
65+
passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
66+
} else if (passwordControl && passwordControl.hasError('weakPassword')) {
67+
delete passwordControl.errors.weakPassword;
68+
if (Object.keys(passwordControl.errors).length === 0) {
69+
passwordControl.setErrors(null);
70+
}
71+
}
72+
}
7473
}

eform-client/src/app/modules/auth/auth.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {MatIconModule} from '@angular/material/icon';
2020
import {MatButtonModule} from '@angular/material/button';
2121
import {MatTooltipModule} from '@angular/material/tooltip';
2222
import {MtxSelectModule} from '@ng-matero/extensions/select';
23-
// import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
23+
import {MatPasswordStrengthModule} from '@angular-material-extensions/password-strength';
2424

2525

2626
@NgModule({
@@ -37,8 +37,8 @@ import {MtxSelectModule} from '@ng-matero/extensions/select';
3737
MatIconModule,
3838
MatButtonModule,
3939
MatTooltipModule,
40-
MtxSelectModule
41-
// MatPasswordStrengthModule,
40+
MtxSelectModule,
41+
MatPasswordStrengthModule,
4242
],
4343
declarations: [
4444
LoginComponent,

eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,17 @@
2323
</mat-form-field>
2424

2525
<!-- Password Strength Meter -->
26-
<!-- TODO: Uncomment once @angular-material-extensions/password-strength is installed -->
27-
<!--
2826
<mat-password-strength
2927
[password]="form.get('newPassword')?.value || ''"
3028
[enableLengthRule]="true"
3129
[enableLowerCaseLetterRule]="true"
3230
[enableUpperCaseLetterRule]="true"
3331
[enableDigitRule]="true"
34-
[enableSpecialCharRule]="true"
35-
[min]="6"
32+
[enableSpecialCharRule]="false"
33+
[min]="8"
3634
[max]="50"
3735
(onStrengthChanged)="onPasswordStrengthChanged($event)">
3836
</mat-password-strength>
39-
-->
4037

4138
<mat-form-field class="mb-4">
4239
<mat-label>{{'Confirm Password' | translate}}</mat-label>
@@ -58,7 +55,7 @@
5855
<mat-error *ngIf="form.controls['newPasswordConfirm'].hasError('required')">{{'Confirm Password field is required'| translate}}</mat-error>
5956
<mat-error *ngIf="form.controls['newPasswordConfirm'].hasError('passwordsNotEqual')">{{'Passwords not equal in New Password and Confirm Password fields'| translate}}</mat-error>
6057
</mat-form-field>
61-
<p>{{ 'The password must contain at least 6 characters.' | translate }}</p>
58+
<p>{{ 'The password must contain at least 8 characters.' | translate }}</p>
6259
</div>
6360
<button
6461
mat-raised-button

eform-client/src/app/modules/auth/components/auth/restore-password-confirmation/restore-password-confirmation.component.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class RestorePasswordConfirmationComponent implements OnInit, OnDestroy {
4242
console.debug('RestorePasswordConfirmationComponent - ngOnInit');
4343
this.route.queryParams.subscribe((params) => {
4444
this.form = this.fb.group({
45-
newPassword: ['', [Validators.required, Validators.minLength(6)]],
45+
newPassword: ['', [Validators.required, Validators.minLength(8)]],
4646
newPasswordConfirm: ['', [Validators.required]],
4747
userId: [params['userId']],
4848
code: [params['code']],
@@ -88,18 +88,17 @@ export class RestorePasswordConfirmationComponent implements OnInit, OnDestroy {
8888
this.newPasswordConfirmVisible = !this.newPasswordConfirmVisible;
8989
}
9090

91-
// TODO: Uncomment once @angular-material-extensions/password-strength is installed
92-
// onPasswordStrengthChanged(strength: number): void {
93-
// this.passwordStrength = strength;
94-
// // Optionally add additional validation based on strength
95-
// const passwordControl = this.form.get('newPassword');
96-
// if (passwordControl && strength < 40) {
97-
// passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
98-
// } else if (passwordControl && passwordControl.hasError('weakPassword')) {
99-
// delete passwordControl.errors.weakPassword;
100-
// if (Object.keys(passwordControl.errors).length === 0) {
101-
// passwordControl.setErrors(null);
102-
// }
103-
// }
104-
// }
91+
onPasswordStrengthChanged(strength: number): void {
92+
this.passwordStrength = strength;
93+
// Optionally add additional validation based on strength
94+
const passwordControl = this.form.get('newPassword');
95+
if (passwordControl && strength < 40) {
96+
passwordControl.setErrors({ ...passwordControl.errors, weakPassword: true });
97+
} else if (passwordControl && passwordControl.hasError('weakPassword')) {
98+
delete passwordControl.errors.weakPassword;
99+
if (Object.keys(passwordControl.errors).length === 0) {
100+
passwordControl.setErrors(null);
101+
}
102+
}
103+
}
105104
}

0 commit comments

Comments
 (0)