Use UserService to determine if user has premium access (#311)

This commit is contained in:
Matt Gibson 2021-03-24 11:15:51 -05:00 committed by GitHub
parent c7ac645eb7
commit 7f3bbd6e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import { ApiService } from '../../abstractions/api.service';
import { I18nService } from '../../abstractions/i18n.service'; import { I18nService } from '../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
import { TokenService } from '../../abstractions/token.service'; import { TokenService } from '../../abstractions/token.service';
import { UserService } from '../../abstractions/user.service';
export class PremiumComponent implements OnInit { export class PremiumComponent implements OnInit {
isPremium: boolean = false; isPremium: boolean = false;
@ -11,10 +12,10 @@ export class PremiumComponent implements OnInit {
refreshPromise: Promise<any>; refreshPromise: Promise<any>;
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected tokenService: TokenService, protected apiService: ApiService) { } protected apiService: ApiService, protected userService: UserService) { }
async ngOnInit() { async ngOnInit() {
this.isPremium = this.tokenService.getPremium(); this.isPremium = await this.userService.canAccessPremium();
} }
async refresh() { async refresh() {
@ -22,7 +23,7 @@ export class PremiumComponent implements OnInit {
this.refreshPromise = this.apiService.refreshIdentityToken(); this.refreshPromise = this.apiService.refreshIdentityToken();
await this.refreshPromise; await this.refreshPromise;
this.platformUtilsService.showToast('success', null, this.i18nService.t('refreshComplete')); this.platformUtilsService.showToast('success', null, this.i18nService.t('refreshComplete'));
this.isPremium = this.tokenService.getPremium(); this.isPremium = await this.userService.canAccessPremium();
} catch { } } catch { }
} }