From f6fdf09fcaa851b8abb3595672f10484f5e7823e Mon Sep 17 00:00:00 2001 From: Chneemann Date: Thu, 23 May 2024 08:53:36 +0200 Subject: [PATCH] error in form validation fixed --- src/app/app.component.ts | 1 + src/app/components/login/login.component.html | 14 +++++++---- .../login/register/register.component.html | 23 ++++++++++++------- .../login/register/register.component.ts | 1 - src/app/services/login.service.ts | 2 -- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d20d105..1cfb409 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -52,6 +52,7 @@ export class AppComponent { this.checkPwResetRoute(); } else { this.router.navigate(['/summary']); + this.sharedService.isBtnDisabled = false; } } diff --git a/src/app/components/login/login.component.html b/src/app/components/login/login.component.html index 341a2ca..f41f247 100644 --- a/src/app/components/login/login.component.html +++ b/src/app/components/login/login.component.html @@ -33,12 +33,14 @@ }
- @if (!mail.valid && mail.touched) { + @if (!mail.valid && mail.touched && !sharedService.isBtnDisabled) {

{{ "login.errorMail0" | translate }}

- } @if (loginSerivce.errorCode == 'auth/invalid-email') { + } @if (loginSerivce.errorCode == 'auth/invalid-email' && + !sharedService.isBtnDisabled) {

{{ "login.errorMail1" | translate }}

} @if (mail.valid && mail.touched && - !checkIfUserEmailIsValid(loginData.mail.toLowerCase())) { + !checkIfUserEmailIsValid(loginData.mail.toLowerCase()) && + !sharedService.isBtnDisabled) {

{{ "login.errorMail2" | translate }}

}
@@ -69,9 +71,11 @@ /> }
- @if (!password.valid && password.touched) { + @if (!password.valid && password.touched && + !sharedService.isBtnDisabled) {

{{ "login.errorPassword0" | translate }}

- } @if (loginSerivce.errorCode == 'auth/invalid-credential') { + } @if (loginSerivce.errorCode == 'auth/invalid-credential' && + !sharedService.isBtnDisabled) {

{{ "login.errorPassword1" | translate }}

}
diff --git a/src/app/components/login/register/register.component.html b/src/app/components/login/register/register.component.html index 90c62de..591d83a 100644 --- a/src/app/components/login/register/register.component.html +++ b/src/app/components/login/register/register.component.html @@ -37,7 +37,7 @@ }
- @if (!name.valid && name.touched) { + @if (!name.valid && name.touched && !sharedService.isBtnDisabled) {

{{ "register.errorName" | translate }}

}
@@ -63,13 +63,16 @@ }
@if(!mail.valid && mail.touched && - !checkIfUserEmailIsValid(registerData.mail.toLowerCase())) { + !checkIfUserEmailIsValid(registerData.mail.toLowerCase()) && + !sharedService.isBtnDisabled) {

{{ "register.errorMail0" | translate }}

} @else { @if (mail.touched && - !checkIfUserEmailIsValid(registerData.mail.toLowerCase())) { + !checkIfUserEmailIsValid(registerData.mail.toLowerCase()) && + !sharedService.isBtnDisabled) {

{{ "register.errorMail1" | translate }}

} @else { @if - (existEmailonServer(registerData.mail.toLowerCase()).length > 0) { + (existEmailonServer(registerData.mail.toLowerCase()).length > 0 && + !sharedService.isBtnDisabled) {

{{ "register.errorMail2" | translate }}

} } }
@@ -99,9 +102,11 @@ /> }
- @if (!password.valid && password.touched) { + @if (!password.valid && password.touched && + !sharedService.isBtnDisabled) {

{{ "register.errorPassword0" | translate }}

- } @else { @if (registerData.password.length < 6 && password.touched) { + } @else { @if (registerData.password.length < 6 && password.touched && + !sharedService.isBtnDisabled) {

{{ "register.errorPassword1" | translate }}

} }
@@ -131,10 +136,12 @@ /> }
- @if (!passwordConfirm.valid && passwordConfirm.touched) { + @if (!passwordConfirm.valid && passwordConfirm.touched && + !sharedService.isBtnDisabled) {

{{ "register.errorPassword0" | translate }}

} @if (registerData.password !== registerData.passwordConfirm && - registerData.password !== "" && registerData.passwordConfirm !== "") { + registerData.password !== "" && registerData.passwordConfirm !== "" && + !sharedService.isBtnDisabled) {

{{ "register.errorPassword2" | translate }}

}
diff --git a/src/app/components/login/register/register.component.ts b/src/app/components/login/register/register.component.ts index 9f07f1e..955d6b6 100644 --- a/src/app/components/login/register/register.component.ts +++ b/src/app/components/login/register/register.component.ts @@ -68,7 +68,6 @@ export class RegisterComponent { } checkIfUserEmailIsValid(emailValue: string) { - const channelNameLenght = emailValue.length; const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/; if (emailRegex.test(emailValue)) { return true; diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts index d4b6cbf..42082a1 100644 --- a/src/app/services/login.service.ts +++ b/src/app/services/login.service.ts @@ -47,7 +47,6 @@ export class LoginService { this.getUserIdInLocalStorage(userData[0].id); this.updateUserOnlineStatus(userData[0].id, true); } - this.sharedService.isBtnDisabled = false; }) .catch((error) => { console.error(error); @@ -128,7 +127,6 @@ export class LoginService { } else { this.ifExistUser(user.uid); } - this.sharedService.isBtnDisabled = false; }); }) .catch((error) => {