From 4238731fb0d1c65943973eba64bf6ffa2de2ec83 Mon Sep 17 00:00:00 2001 From: Gion-Andri Cantieni Date: Fri, 10 Nov 2023 19:59:28 +0100 Subject: [PATCH] feat: show more explicit error for too short password --- .../pages/change-password/change-password.component.html | 7 ++++++- .../pages/change-password/change-password.component.ts | 5 +++++ .../pages/confirm-password/confirm-password.component.html | 7 ++++++- .../pages/confirm-password/confirm-password.component.ts | 7 ++++++- src/app/user-area/pages/login/login.component.ts | 4 ++-- src/app/user-area/pages/register/register.component.html | 7 ++++++- src/app/user-area/pages/register/register.component.ts | 5 +++++ 7 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/app/user-area/pages/change-password/change-password.component.html b/src/app/user-area/pages/change-password/change-password.component.html index d5256c9..ebed324 100644 --- a/src/app/user-area/pages/change-password/change-password.component.html +++ b/src/app/user-area/pages/change-password/change-password.component.html @@ -31,7 +31,12 @@

Midar il pled-clav

formControlName="newPassword" [class.is-invalid]="isFieldInvalid('newPassword')">
- Endatescha tes pled-clav nov cun almain 8 caracters. + + Endatescha in pled-clav nov. + + + Il pled-clav nov sto avair ina lunghezza dad almain 8 caracters. +
diff --git a/src/app/user-area/pages/change-password/change-password.component.ts b/src/app/user-area/pages/change-password/change-password.component.ts index d4ca2ee..5328e54 100644 --- a/src/app/user-area/pages/change-password/change-password.component.ts +++ b/src/app/user-area/pages/change-password/change-password.component.ts @@ -26,6 +26,11 @@ export class ChangePasswordComponent { return this.f.get(fieldName)!.invalid && (this.f.get(fieldName)!.dirty || this.f.get(fieldName)!.touched); } + isFieldError(fieldName: string, errorName: string) { + const field = this.f.get(fieldName)!; + return field.hasError(errorName); + } + update() { this.f.markAllAsTouched(); diff --git a/src/app/user-area/pages/confirm-password/confirm-password.component.html b/src/app/user-area/pages/confirm-password/confirm-password.component.html index 1e83367..f49eef0 100644 --- a/src/app/user-area/pages/confirm-password/confirm-password.component.html +++ b/src/app/user-area/pages/confirm-password/confirm-password.component.html @@ -22,7 +22,12 @@

Midar tes pled-clav

- Endatescha tes pled-clav. + + Endatescha in pled-clav. + + + Il pled-clav sto avair ina lunghezza dad almain 8 caracters. +
diff --git a/src/app/user-area/pages/confirm-password/confirm-password.component.ts b/src/app/user-area/pages/confirm-password/confirm-password.component.ts index b4f79b9..9615076 100644 --- a/src/app/user-area/pages/confirm-password/confirm-password.component.ts +++ b/src/app/user-area/pages/confirm-password/confirm-password.component.ts @@ -25,7 +25,7 @@ export class ConfirmPasswordComponent { private fb: FormBuilder, ) { this.f = this.fb.group({ - password: ['', [Validators.required]], + password: ['', [Validators.required, Validators.minLength(8)]], }); } @@ -68,4 +68,9 @@ export class ConfirmPasswordComponent { isFieldInvalid(fieldName: string) { return this.f.get(fieldName)!.invalid && (this.f.get(fieldName)!.dirty || this.f.get(fieldName)!.touched); } + + isFieldError(fieldName: string, errorName: string) { + const field = this.f.get(fieldName)!; + return field.hasError(errorName); + } } diff --git a/src/app/user-area/pages/login/login.component.ts b/src/app/user-area/pages/login/login.component.ts index e36fa5c..e2624c7 100644 --- a/src/app/user-area/pages/login/login.component.ts +++ b/src/app/user-area/pages/login/login.component.ts @@ -48,13 +48,13 @@ export class LoginComponent implements OnInit, OnDestroy { this.errorMessage = { type: 'danger', title: 'Conto betg activà', - message: "Tes conto n'è betg activ. Controllescha sche ti has confermà tia adressa dad e-mail" + message: "Tes conto n'è betg activ. Controllescha sche ti has confermà tia adressa dad e-mail." }; } else { this.errorMessage = { type: 'danger', title: 'Errur', - message: "Betg pussaivel da s'annunziar cun questas datas" + message: "Betg pussaivel da s'annunziar cun questas datas." }; } console.error(error); diff --git a/src/app/user-area/pages/register/register.component.html b/src/app/user-area/pages/register/register.component.html index 0b4de7a..83ceebb 100644 --- a/src/app/user-area/pages/register/register.component.html +++ b/src/app/user-area/pages/register/register.component.html @@ -43,7 +43,12 @@

Crear in nov conto d’utilisad*ra

- Endatescha p.pl. ina pled-clav cun almain 8 caracters. + + Endatescha in pled-clav. + + + Il pled-clav sto avair ina lunghezza dad almain 8 caracters. +
diff --git a/src/app/user-area/pages/register/register.component.ts b/src/app/user-area/pages/register/register.component.ts index 9246055..d053f8d 100644 --- a/src/app/user-area/pages/register/register.component.ts +++ b/src/app/user-area/pages/register/register.component.ts @@ -67,6 +67,11 @@ export class RegisterComponent implements OnInit { return this.f.get(fieldName)!.invalid && (this.f.get(fieldName)!.dirty || this.f.get(fieldName)!.touched); } + isFieldError(fieldName: string, errorName: string) { + const field = this.f.get(fieldName)!; + return field.hasError(errorName); + } + private initForm() { this.f = this.fb.group({ firstName: ['', Validators.required],