Add email re-validation handling with UI feedback and backend validation to prevent duplicate email verification attempts
This commit is contained in:
@@ -58,7 +58,7 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
protected verifiedEmails = computed(() => this.emails()
|
||||
.filter(email => email.verified)
|
||||
.map(email => email.email.toLowerCase()));
|
||||
protected validatedMail = signal<boolean>(false);
|
||||
protected emailIsValid = signal<boolean>(false);
|
||||
protected dialog = inject(MatDialog);
|
||||
|
||||
constructor(
|
||||
@@ -73,10 +73,13 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
this.emails.set(emails);
|
||||
});
|
||||
this.form.valueChanges.subscribe(() => {
|
||||
if (this.form.getRawValue().email.toLowerCase() in this.verifiedEmails()) {
|
||||
this.validatedMail.set(true);
|
||||
if (this.verifiedEmails().includes(this.form.getRawValue().email.toLowerCase())) {
|
||||
this.emailIsValid.set(true);
|
||||
} else {
|
||||
this.emailIsValid.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -225,7 +228,7 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
}
|
||||
|
||||
protected validateMailOrNextPage() {
|
||||
if (this.validatedMail()) {
|
||||
if (this.emailIsValid()) {
|
||||
this.nextPage();
|
||||
return;
|
||||
}
|
||||
@@ -234,7 +237,7 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
});
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result === true) {
|
||||
this.validatedMail.set(true);
|
||||
this.emailIsValid.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user