Improve email verification flow by adding verified email pre-fill, validation handling, and dialog-based verification support.
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import {Component, inject, Input, input, signal} from '@angular/core';
|
||||
import {Component, Inject, inject, input, signal} from '@angular/core';
|
||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {MatInput, MatLabel} from '@angular/material/input';
|
||||
import {MatFormFieldModule} from '@angular/material/form-field';
|
||||
import {MailService, SubmitEmail, VerifyCode} from '@api';
|
||||
import {AuthService} from '@services/auth.service';
|
||||
import {MatButtonModule} from '@angular/material/button';
|
||||
import {MatDialogActions, MatDialogContent, MatDialogRef, MatDialogTitle} from '@angular/material/dialog';
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogActions,
|
||||
MatDialogContent,
|
||||
MatDialogRef,
|
||||
MatDialogTitle
|
||||
} from '@angular/material/dialog';
|
||||
import {interval, Subscription} from 'rxjs';
|
||||
|
||||
@Component({
|
||||
@@ -38,10 +44,11 @@ export class SentComponent {
|
||||
|
||||
private mailService = inject(MailService);
|
||||
private authService = inject(AuthService);
|
||||
protected readonly email: string;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<SentComponent>,
|
||||
@Input() public email: string
|
||||
@Inject(MAT_DIALOG_DATA) public data: InputMail
|
||||
) {
|
||||
this.form = new FormGroup({
|
||||
code: new FormControl('', {
|
||||
@@ -49,6 +56,8 @@ export class SentComponent {
|
||||
validators: [Validators.required, Validators.minLength(6), Validators.maxLength(6)]
|
||||
})
|
||||
});
|
||||
this.email = data.email;
|
||||
this.mailService.submitEmailForVerification({email: this.email.toLowerCase()}).subscribe();
|
||||
}
|
||||
|
||||
public onSubmit() {
|
||||
@@ -81,7 +90,6 @@ export class SentComponent {
|
||||
|
||||
this.mailService.resendVerificationEmail(submitEmail).subscribe({
|
||||
next: (response) => {
|
||||
// Start cooldown timer
|
||||
this.startResendCooldown();
|
||||
},
|
||||
error: (error) => {
|
||||
@@ -147,3 +155,7 @@ interface VerifyMailData {
|
||||
verified: boolean;
|
||||
mail: string;
|
||||
}
|
||||
|
||||
interface InputMail {
|
||||
email: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user