All files / app/identity/verify-email verify-email.component.ts

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                  1x                             3x 3x   3x 3x      
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { Router, RouterLink } from '@angular/router';
 
import { SpinnerComponent } from '@app/shared/spinner/spinner.component';
 
import { getState } from '../actions/get-state';
import { AuthErrorMessagesComponent } from '../auth-error-messages/auth-error-messages.component';
import { VerifyEmailService } from './verify-email.service';
import type { VerifyEmailResult } from './verify-email.service';
 
/**
 * Marks the user's email as verified.
 */
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    AsyncPipe,
    AuthErrorMessagesComponent,
    SpinnerComponent,
    RouterLink,
  ],
  selector: 'app-verify-email',
  templateUrl: './verify-email.component.html',
})
export class VerifyEmailComponent {
  /**
   * Observable wrapper around the template that performs the actual verification and displays the
   * results of the verification.
   */
  public readonly vm: Promise<VerifyEmailResult>;
 
  private readonly _router: Router;
  private readonly _service: VerifyEmailService;
 
  /**
   * Gets the current navigation statically to obtain the oobCode from Firebase needed to verify the
   * email address of the User.
   */
  constructor() {
    this._router = inject(Router);
    this._service = inject(VerifyEmailService);
 
    const { continueUrl, oobCode } = getState(this._router.getCurrentNavigation());
    this.vm = this._service.verifyEmail(oobCode, continueUrl);
  }
}