mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 11:13:46 +00:00
user canAccessPremium checks
This commit is contained in:
@@ -22,14 +22,14 @@
|
||||
<h3 class="mb-0">
|
||||
{{p.name}}
|
||||
<i class="fa fa-check text-success fa-fw" *ngIf="p.enabled" title="{{'enabled' | i18n}}"></i>
|
||||
<a href="#" appStopClick class="badge badge-primary" *ngIf="!premium && p.premium" (click)="premiumRequired()">
|
||||
<a href="#" appStopClick class="badge badge-primary" *ngIf="!canAccessPremium && p.premium" (click)="premiumRequired()">
|
||||
{{'premium' | i18n}}
|
||||
</a>
|
||||
</h3>
|
||||
{{p.description}}
|
||||
</div>
|
||||
<div class="ml-auto">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" [disabled]="!premium && p.premium" (click)="manage(p.type)">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" [disabled]="!canAccessPremium && p.premium" (click)="manage(p.type)">
|
||||
{{'manage' | i18n}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { TokenService } from 'jslib/abstractions/token.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { TwoFactorProviders } from 'jslib/services/auth.service';
|
||||
|
||||
@@ -38,16 +38,16 @@ export class TwoFactorSetupComponent implements OnInit {
|
||||
|
||||
organizationId: string;
|
||||
providers: any[] = [];
|
||||
premium: boolean;
|
||||
canAccessPremium: boolean;
|
||||
loading = true;
|
||||
|
||||
private modal: ModalComponent = null;
|
||||
|
||||
constructor(protected apiService: ApiService, protected tokenService: TokenService,
|
||||
constructor(protected apiService: ApiService, protected userService: UserService,
|
||||
protected componentFactoryResolver: ComponentFactoryResolver, protected messagingService: MessagingService) { }
|
||||
|
||||
async ngOnInit() {
|
||||
this.premium = this.tokenService.getPremium();
|
||||
this.canAccessPremium = await this.userService.canAccessPremium();
|
||||
|
||||
for (const key in TwoFactorProviders) {
|
||||
if (!TwoFactorProviders.hasOwnProperty(key)) {
|
||||
@@ -128,8 +128,7 @@ export class TwoFactorSetupComponent implements OnInit {
|
||||
}
|
||||
|
||||
async premiumRequired() {
|
||||
const premium = await this.tokenService.getPremium();
|
||||
if (!premium) {
|
||||
if (!this.canAccessPremium) {
|
||||
this.messagingService.send('premiumRequired');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ export class UserBillingComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
const premium = this.tokenService.getPremium();
|
||||
if (premium) {
|
||||
if (this.tokenService.getPremium()) {
|
||||
this.loading = true;
|
||||
this.billing = await this.apiService.getUserBilling();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user