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"
|
||||
name="mail"
|
||||
#mail="ngModel"
|
||||
placeholder="{{ 'login.email' | translate }}"
|
||||
placeholder="{{ 'forgotPW.email' | translate }}"
|
||||
class="custom-input"
|
||||
autocomplete="email"
|
||||
[(ngModel)]="pwResetData.mail"
|
||||
|
|
@ -33,11 +33,17 @@
|
|||
<img class="custom-img" alt="" />
|
||||
}
|
||||
<div class="error-msg">
|
||||
@if (!mail.valid && mail.touched) {
|
||||
<p>{{ "forgotPW.errorMail0" | translate }}</p>
|
||||
} @if (loginSerivce.errorCode == 'auth/invalid-email') {
|
||||
<p>{{ "forgotPW.errorMail1" | translate }}</p>
|
||||
}
|
||||
@if(!mail.valid && mail.touched &&
|
||||
!checkIfUserEmailIsValid(pwResetData.mail.toLowerCase())) {
|
||||
<p>{{ "register.errorMail0" | 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 class="notice">
|
||||
|
|
|
|||
|
|
@ -45,6 +45,12 @@ export class ForgotPwComponent {
|
|||
}
|
||||
}
|
||||
|
||||
existEmailonServer(mail: string) {
|
||||
return this.firebaseService
|
||||
.getAllUsers()
|
||||
.filter((user) => user.email === mail);
|
||||
}
|
||||
|
||||
checkIfUserEmailIsValid(emailValue: string) {
|
||||
const channelNameLenght = emailValue.length;
|
||||
const emailRegex = /^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,}$/;
|
||||
|
|
|
|||
|
|
@ -62,12 +62,13 @@
|
|||
}
|
||||
<div class="error-msg">
|
||||
@if(!mail.valid && mail.touched &&
|
||||
!checkIfUserEmailIsValid(registerData.mail)) {
|
||||
!checkIfUserEmailIsValid(registerData.mail.toLowerCase())) {
|
||||
<p>{{ "register.errorMail0" | translate }}</p>
|
||||
} @else { @if (mail.touched &&
|
||||
!checkIfUserEmailIsValid(registerData.mail)) {
|
||||
!checkIfUserEmailIsValid(registerData.mail.toLowerCase())) {
|
||||
<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>
|
||||
} } }
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
"forgot": "Passwort zurücksetzen",
|
||||
"email": "Ihre E-Mail",
|
||||
"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"
|
||||
},
|
||||
"register": {
|
||||
|
|
@ -33,6 +31,7 @@
|
|||
"errorMail0": "Sie müssen eine E-Mail Adresse eingeben!",
|
||||
"errorMail1": "Dies ist kein gültiges E-Mail-Format!",
|
||||
"errorMail2": "Diese E-Mail existiert bereits!",
|
||||
"errorMail3": "Diese E-Mail existiert nicht!",
|
||||
"errorPassword0": "Sie müssen ein Passwort eingeben!",
|
||||
"errorPassword1": "Das Passwort muss aus mindestens 6 Zeichen bestehen!",
|
||||
"errorPassword2": "Die Passwörter stimmen nicht überein!"
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
"forgot": "Reset Password",
|
||||
"email": "Your Email",
|
||||
"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."
|
||||
},
|
||||
"register": {
|
||||
|
|
@ -33,6 +31,7 @@
|
|||
"errorMail0": "You must enter a mail!",
|
||||
"errorMail1": "This is not a valid email format!",
|
||||
"errorMail2": "This email already exists!",
|
||||
"errorMail3": "This email does not exist!",
|
||||
"errorPassword0": "You must enter a password!",
|
||||
"errorPassword1": "The password must consist of at least 6 characters!",
|
||||
"errorPassword2": "The passwords don't match!"
|
||||
|
|
|
|||
Loading…
Reference in a new issue