import { CommonModule } from "@angular/common"; import { Component, EventEmitter, Output } from "@angular/core"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { TokenService } from "@bitwarden/common/auth/abstractions/token.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { AsyncActionsModule, BannerModule, ButtonModule, LinkModule } from "@bitwarden/components"; @Component({ standalone: true, selector: "app-verify-email", templateUrl: "verify-email.component.html", imports: [AsyncActionsModule, BannerModule, ButtonModule, CommonModule, JslibModule, LinkModule], }) export class VerifyEmailComponent { actionPromise: Promise; @Output() onVerified = new EventEmitter(); @Output() onDismiss = new EventEmitter(); constructor( private apiService: ApiService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private tokenService: TokenService, ) {} async verifyEmail(): Promise { await this.apiService.refreshIdentityToken(); if (await this.tokenService.getEmailVerified()) { this.onVerified.emit(true); this.platformUtilsService.showToast("success", null, this.i18nService.t("emailVerified")); return; } await this.apiService.postAccountVerifyEmail(); this.platformUtilsService.showToast( "success", null, this.i18nService.t("checkInboxForVerification"), ); } send = async () => { await this.verifyEmail(); }; }