All files / app/identity/recover-email recover-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 49                                                    1x                             4x 4x   4x 4x      
import { AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { Router, RouterLink } from '@angular/router';
import type { Observable } from 'rxjs';
 
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 { RecoverEmailService } from './recover-email.service';
import type { RecoverEmailResults } from './recover-email.service';
 
/**
 * Reverts Firebase User email change.
 */
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    AsyncPipe,
    AuthErrorMessagesComponent,
    RouterLink,
    SpinnerComponent,
  ],
  selector: 'app-recover-email',
  templateUrl: './recover-email.component.html',
})
export class RecoverEmailComponent {
  /**
   * Observable wrapper around the template that performs the actual email recovery and displays the
   * results.
   */
  public readonly vm$: Observable<RecoverEmailResults>;
 
  private readonly _router: Router;
  private readonly _service: RecoverEmailService;
 
  /**
   * Gets the current navigation statically to obtain the oobCode from Firebase needed to recover
   * the previous email address for the User.
   */
  constructor() {
    this._router = inject(Router);
    this._service = inject(RecoverEmailService);
 
    const { oobCode } = getState(this._router.getCurrentNavigation());
    this.vm$ = this._service.recoverEmail$(oobCode);
  }
}