mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[EC-243] Grant premium status when member accepts org invite (#2870)
* Rename setCanAccessPremium to setHasPremiumPersonally * Add hasPremiumFromOrganization * Refactor stateService methods * Add getHasPremiumPersonally, deprecate tokenService.getPremium
This commit is contained in:
@@ -45,8 +45,8 @@ export class PremiumComponent implements OnInit {
|
||||
|
||||
async ngOnInit() {
|
||||
this.canAccessPremium = await this.stateService.getCanAccessPremium();
|
||||
const premium = await this.tokenService.getPremium();
|
||||
if (premium) {
|
||||
const premiumPersonally = await this.stateService.getHasPremiumPersonally();
|
||||
if (premiumPersonally) {
|
||||
this.router.navigate(["/settings/subscription/user-subscription"]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async load() {
|
||||
this.premium = await this.tokenService.getPremium();
|
||||
this.premium = await this.stateService.getHasPremiumPersonally();
|
||||
this.hasFamilySponsorshipAvailable = await this.organizationService.canManageSponsorships();
|
||||
const hasPremiumFromOrg = await this.stateService.getCanAccessPremium();
|
||||
const hasPremiumFromOrg = await this.stateService.getHasPremiumFromOrganization();
|
||||
let billing = null;
|
||||
if (!this.selfHosted) {
|
||||
billing = await this.apiService.getUserBillingHistory();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
||||
import { TokenService } from "jslib-common/abstractions/token.service";
|
||||
import { StateService } from "jslib-common/abstractions/state.service";
|
||||
|
||||
@Component({
|
||||
selector: "app-subscription",
|
||||
@@ -12,12 +12,12 @@ export class SubscriptionComponent {
|
||||
selfHosted: boolean;
|
||||
|
||||
constructor(
|
||||
private tokenService: TokenService,
|
||||
private stateService: StateService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.hasPremium = await this.tokenService.getPremium();
|
||||
this.hasPremium = await this.stateService.getHasPremiumPersonally();
|
||||
this.selfHosted = this.platformUtilsService.isSelfHost();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ApiService } from "jslib-common/abstractions/api.service";
|
||||
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
||||
import { LogService } from "jslib-common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
||||
import { TokenService } from "jslib-common/abstractions/token.service";
|
||||
import { StateService } from "jslib-common/abstractions/state.service";
|
||||
import { SubscriptionResponse } from "jslib-common/models/response/subscriptionResponse";
|
||||
|
||||
@Component({
|
||||
@@ -25,7 +25,7 @@ export class UserSubscriptionComponent implements OnInit {
|
||||
reinstatePromise: Promise<any>;
|
||||
|
||||
constructor(
|
||||
private tokenService: TokenService,
|
||||
private stateService: StateService,
|
||||
private apiService: ApiService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
@@ -45,7 +45,7 @@ export class UserSubscriptionComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.tokenService.getPremium()) {
|
||||
if (this.stateService.getHasPremiumPersonally()) {
|
||||
this.loading = true;
|
||||
this.sub = await this.apiService.getUserSubscription();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user