diff --git a/jslib b/jslib index 45da8aa9eb..81c21418ec 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 45da8aa9eb4dd7e12c9fa67ed09189bc4d5ed2f1 +Subproject commit 81c21418ec965221b4d322008f9da0ab7b9037d0 diff --git a/src/background/main.background.ts b/src/background/main.background.ts index c1aaa4421e..e63d9b658a 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -155,8 +155,7 @@ export default class MainBackground { this.storageService, this.messagingService, async (expired: boolean) => await this.logout(expired)); this.passwordGenerationService = new PasswordGenerationService(this.cryptoService, this.storageService); this.totpService = new TotpService(this.storageService, cryptoFunctionService); - this.autofillService = new AutofillService(this.cipherService, this.tokenService, - this.totpService); + this.autofillService = new AutofillService(this.cipherService, this.userService, this.totpService); this.containerService = new ContainerService(this.cryptoService, this.platformUtilsService); this.auditService = new AuditService(cryptoFunctionService, this.apiService); this.exportService = new ExportService(this.folderService, this.cipherService, this.apiService); diff --git a/src/popup/vault/view.component.ts b/src/popup/vault/view.component.ts index 670b74a452..6ee19d4ffc 100644 --- a/src/popup/vault/view.component.ts +++ b/src/popup/vault/view.component.ts @@ -19,6 +19,7 @@ import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { TokenService } from 'jslib/abstractions/token.service'; import { TotpService } from 'jslib/abstractions/totp.service'; +import { UserService } from 'jslib/abstractions/user.service'; import { BroadcasterService } from 'jslib/angular/services/broadcaster.service'; @@ -38,9 +39,9 @@ export class ViewComponent extends BaseViewComponent { auditService: AuditService, private route: ActivatedRoute, private router: Router, private location: Location, broadcasterService: BroadcasterService, ngZone: NgZone, - changeDetectorRef: ChangeDetectorRef) { + changeDetectorRef: ChangeDetectorRef, userService: UserService) { super(cipherService, totpService, tokenService, toasterService, cryptoService, platformUtilsService, - i18nService, analytics, auditService, window, broadcasterService, ngZone, changeDetectorRef); + i18nService, analytics, auditService, window, broadcasterService, ngZone, changeDetectorRef, userService); } ngOnInit() { diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index 8dd3f99230..de144f00ad 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -13,8 +13,8 @@ import { AutofillService as AutofillServiceInterface } from './abstractions/auto import { CipherService, - TokenService, TotpService, + UserService, } from 'jslib/abstractions'; const CardAttributes: string[] = ['autoCompleteType', 'data-stripe', 'htmlName', 'htmlID', 'label-tag', @@ -103,7 +103,7 @@ var IsoProvinces: { [id: string]: string; } = { /* tslint:enable */ export default class AutofillService implements AutofillServiceInterface { - constructor(private cipherService: CipherService, private tokenService: TokenService, + constructor(private cipherService: CipherService, private userService: UserService, private totpService: TotpService) { } getFormsWithPasswordFields(pageDetails: AutofillPageDetails): any[] { @@ -145,6 +145,7 @@ export default class AutofillService implements AutofillServiceInterface { throw new Error('Nothing to auto-fill.'); } + const canAccessPremium = await this.userService.canAccessPremium(); let didAutofill = false; options.pageDetails.forEach((pd: any) => { // make sure we're still on correct tab @@ -174,7 +175,7 @@ export default class AutofillService implements AutofillServiceInterface { }, { frameId: pd.frameId }); if (options.cipher.type !== CipherType.Login || totpPromise || options.skipTotp || - !options.cipher.login.totp || !this.tokenService.getPremium()) { + !options.cipher.login.totp || !canAccessPremium) { return; }