Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

#597: added email validator to reset form, show hint if the email isn… #637

Merged
merged 5 commits into from
Apr 19, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/webFrontend/src/app/auth/reset/reset.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export class ResetComponent implements OnInit {
}

requestReset() {
if (!this.resetForm.valid) {
this.snackBar.open('The email address you entered is not valid.', 'Dismiss');
return;
}

this.showProgress.toggleLoadingGlobal(true);
this.loading = true;
this.authenticationService.requestReset(this.resetForm.value.email.replace(/\s/g, '').toLowerCase())
Expand Down Expand Up @@ -80,7 +85,7 @@ export class ResetComponent implements OnInit {
this.resetForm = this.formBuilder.group({});
} else {
this.resetForm = this.formBuilder.group({
email: ['', Validators.required]
email: ['', Validators.email ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Validation does work properly. A email with without "@" does throw a error. A email with missing domain ending, like ".de", will accept. This should also fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An email can still be valid without a top level domain: see https://en.wikipedia.org/wiki/Email_address#Examples
But if it really is required to only support emails with tld, we would need to write a custom validator and couldn't use the default angular email validator

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukas-schardt interesting fact, didn't know that, but it is prohibited to used those since 2013, so would propose using a custom validator.

});
}
}
Expand Down