form validation
This commit is contained in:
parent
a23f81a47f
commit
cca5bd8f73
5 changed files with 24 additions and 13 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
id="mail"
|
id="mail"
|
||||||
name="mail"
|
name="mail"
|
||||||
#mail="ngModel"
|
#mail="ngModel"
|
||||||
placeholder="{{ 'login.email' | translate }}"
|
placeholder="{{ 'forgotPW.email' | translate }}"
|
||||||
class="custom-input"
|
class="custom-input"
|
||||||
autocomplete="email"
|
autocomplete="email"
|
||||||
[(ngModel)]="pwResetData.mail"
|
[(ngModel)]="pwResetData.mail"
|
||||||
|
|
@ -33,11 +33,17 @@
|
||||||
<img class="custom-img" alt="" />
|
<img class="custom-img" alt="" />
|
||||||
}
|
}
|
||||||
<div class="error-msg">
|
<div class="error-msg">
|
||||||
@if (!mail.valid && mail.touched) {
|
@if(!mail.valid && mail.touched &&
|
||||||
<p>{{ "forgotPW.errorMail0" | translate }}</p>
|
!checkIfUserEmailIsValid(pwResetData.mail.toLowerCase())) {
|
||||||
} @if (loginSerivce.errorCode == 'auth/invalid-email') {
|
<p>{{ "register.errorMail0" | translate }}</p>
|
||||||
<p>{{ "forgotPW.errorMail1" | translate }}</p>
|
} @else { @if (mail.touched &&
|
||||||
}
|
!checkIfUserEmailIsValid(pwResetData.mail.toLowerCase())) {
|
||||||
|
<p>{{ "register.errorMail1" | translate }}</p>
|
||||||
|
} @else {
|
||||||
|
@if(existEmailonServer(pwResetData.mail.toLowerCase()).length !== 1 &&
|
||||||
|
mail.touched) {
|
||||||
|
<p>{{ "register.errorMail3" | translate }}</p>
|
||||||
|
} } }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="notice">
|
<div class="notice">
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ export class ForgotPwComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
existEmailonServer(mail: string) {
|
||||||
|
return this.firebaseService
|
||||||
|
.getAllUsers()
|
||||||
|
.filter((user) => user.email === mail);
|
||||||
|
}
|
||||||
|
|
||||||
checkIfUserEmailIsValid(emailValue: string) {
|
checkIfUserEmailIsValid(emailValue: string) {
|
||||||
const channelNameLenght = emailValue.length;
|
const channelNameLenght = emailValue.length;
|
||||||
const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/;
|
const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/;
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,13 @@
|
||||||
}
|
}
|
||||||
<div class="error-msg">
|
<div class="error-msg">
|
||||||
@if(!mail.valid && mail.touched &&
|
@if(!mail.valid && mail.touched &&
|
||||||
!checkIfUserEmailIsValid(registerData.mail)) {
|
!checkIfUserEmailIsValid(registerData.mail.toLowerCase())) {
|
||||||
<p>{{ "register.errorMail0" | translate }}</p>
|
<p>{{ "register.errorMail0" | translate }}</p>
|
||||||
} @else { @if (mail.touched &&
|
} @else { @if (mail.touched &&
|
||||||
!checkIfUserEmailIsValid(registerData.mail)) {
|
!checkIfUserEmailIsValid(registerData.mail.toLowerCase())) {
|
||||||
<p>{{ "register.errorMail1" | translate }}</p>
|
<p>{{ "register.errorMail1" | translate }}</p>
|
||||||
} @else { @if (existEmailonServer(registerData.mail).length > 0) {
|
} @else { @if
|
||||||
|
(existEmailonServer(registerData.mail.toLowerCase()).length > 0) {
|
||||||
<p>{{ "register.errorMail2" | translate }}</p>
|
<p>{{ "register.errorMail2" | translate }}</p>
|
||||||
} } }
|
} } }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
"forgot": "Passwort zurücksetzen",
|
"forgot": "Passwort zurücksetzen",
|
||||||
"email": "Ihre E-Mail",
|
"email": "Ihre E-Mail",
|
||||||
"sendMail": "E-Mail senden",
|
"sendMail": "E-Mail senden",
|
||||||
"errorMail0": "Sie müssen eine E-Mail Adresse eingeben!",
|
|
||||||
"errorMail1": "Diese E-Mail Adresse existiert nicht!",
|
|
||||||
"notice": "Wir senden Ihnen eine E-Mail, über die Sie Ihr Passwort ändern können"
|
"notice": "Wir senden Ihnen eine E-Mail, über die Sie Ihr Passwort ändern können"
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
|
|
@ -33,6 +31,7 @@
|
||||||
"errorMail0": "Sie müssen eine E-Mail Adresse eingeben!",
|
"errorMail0": "Sie müssen eine E-Mail Adresse eingeben!",
|
||||||
"errorMail1": "Dies ist kein gültiges E-Mail-Format!",
|
"errorMail1": "Dies ist kein gültiges E-Mail-Format!",
|
||||||
"errorMail2": "Diese E-Mail existiert bereits!",
|
"errorMail2": "Diese E-Mail existiert bereits!",
|
||||||
|
"errorMail3": "Diese E-Mail existiert nicht!",
|
||||||
"errorPassword0": "Sie müssen ein Passwort eingeben!",
|
"errorPassword0": "Sie müssen ein Passwort eingeben!",
|
||||||
"errorPassword1": "Das Passwort muss aus mindestens 6 Zeichen bestehen!",
|
"errorPassword1": "Das Passwort muss aus mindestens 6 Zeichen bestehen!",
|
||||||
"errorPassword2": "Die Passwörter stimmen nicht überein!"
|
"errorPassword2": "Die Passwörter stimmen nicht überein!"
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
"forgot": "Reset Password",
|
"forgot": "Reset Password",
|
||||||
"email": "Your Email",
|
"email": "Your Email",
|
||||||
"sendMail": "Send Mail",
|
"sendMail": "Send Mail",
|
||||||
"errorMail0": "You must enter a mail!",
|
|
||||||
"errorMail1": "This email address does not exist!",
|
|
||||||
"notice": "We will send you an email to change your password."
|
"notice": "We will send you an email to change your password."
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
|
|
@ -33,6 +31,7 @@
|
||||||
"errorMail0": "You must enter a mail!",
|
"errorMail0": "You must enter a mail!",
|
||||||
"errorMail1": "This is not a valid email format!",
|
"errorMail1": "This is not a valid email format!",
|
||||||
"errorMail2": "This email already exists!",
|
"errorMail2": "This email already exists!",
|
||||||
|
"errorMail3": "This email does not exist!",
|
||||||
"errorPassword0": "You must enter a password!",
|
"errorPassword0": "You must enter a password!",
|
||||||
"errorPassword1": "The password must consist of at least 6 characters!",
|
"errorPassword1": "The password must consist of at least 6 characters!",
|
||||||
"errorPassword2": "The passwords don't match!"
|
"errorPassword2": "The passwords don't match!"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue