From 85893f5f9efb201a45c5af54896a82e6eb185108 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 9 Apr 2021 07:05:15 +1000 Subject: [PATCH] Require user to verify email to use file Send (#331) * Require user to verify email to use file Send * Simplify alertShown logic --- .../components/send/add-edit.component.ts | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/angular/components/send/add-edit.component.ts b/src/angular/components/send/add-edit.component.ts index 4a30e5ef6c..5f7536ac0a 100644 --- a/src/angular/components/send/add-edit.component.ts +++ b/src/angular/components/send/add-edit.component.ts @@ -17,6 +17,7 @@ import { MessagingService } from '../../../abstractions/messaging.service'; import { PlatformUtilsService } from '../../../abstractions/platformUtils.service'; import { PolicyService } from '../../../abstractions/policy.service'; import { SendService } from '../../../abstractions/send.service'; +import { TokenService } from '../../../abstractions/token.service'; import { UserService } from '../../../abstractions/user.service'; import { SendFileView } from '../../../models/view/sendFileView'; @@ -67,7 +68,8 @@ export class AddEditComponent implements OnInit { deletionDateSelect = 168; expirationDateSelect: number = null; canAccessPremium = true; - premiumRequiredAlertShown = false; + emailVerified = true; + alertShown = false; showOptions = false; safariDeletionTime: string; @@ -80,7 +82,8 @@ export class AddEditComponent implements OnInit { constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService, protected datePipe: DatePipe, protected sendService: SendService, protected userService: UserService, - protected messagingService: MessagingService, protected policyService: PolicyService) { + protected messagingService: MessagingService, protected policyService: PolicyService, + protected tokenService: TokenService) { this.typeOptions = [ { name: i18nService.t('sendTypeFile'), value: SendType.File }, { name: i18nService.t('sendTypeText'), value: SendType.Text }, @@ -170,7 +173,8 @@ export class AddEditComponent implements OnInit { }); this.canAccessPremium = await this.userService.canAccessPremium(); - if (!this.canAccessPremium) { + this.emailVerified = this.tokenService.getEmailVerified(); + if (!this.canAccessPremium || !this.emailVerified) { this.type = SendType.Text; } @@ -355,9 +359,15 @@ export class AddEditComponent implements OnInit { } typeChanged() { - if (!this.canAccessPremium && this.send.type === SendType.File && !this.premiumRequiredAlertShown) { - this.premiumRequiredAlertShown = true; - this.messagingService.send('premiumRequired'); + if (this.send.type === SendType.File && !this.alertShown) + { + if (!this.canAccessPremium) { + this.alertShown = true; + this.messagingService.send('premiumRequired'); + } else if (!this.emailVerified) { + this.alertShown = true; + this.messagingService.send('emailVerificationRequired'); + } } }