|
|
|
@ -2,7 +2,6 @@ import { DataService } from '@ghostfolio/client/services/data.service';
|
|
|
|
|
import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service';
|
|
|
|
|
import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service';
|
|
|
|
|
import { InfoItem } from '@ghostfolio/common/interfaces';
|
|
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
HTTP_INTERCEPTORS,
|
|
|
|
@ -25,7 +24,6 @@ import { catchError, tap } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class HttpResponseInterceptor implements HttpInterceptor {
|
|
|
|
|
public hasPermissionForSubscription: boolean;
|
|
|
|
|
public info: InfoItem;
|
|
|
|
|
public snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
|
|
|
|
|
|
|
|
|
@ -37,11 +35,6 @@ export class HttpResponseInterceptor implements HttpInterceptor {
|
|
|
|
|
private webAuthnService: WebAuthnService
|
|
|
|
|
) {
|
|
|
|
|
this.info = this.dataService.fetchInfo();
|
|
|
|
|
|
|
|
|
|
this.hasPermissionForSubscription = hasPermission(
|
|
|
|
|
this.info?.globalPermissions,
|
|
|
|
|
permissions.enableSubscription
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public intercept(
|
|
|
|
@ -65,12 +58,8 @@ export class HttpResponseInterceptor implements HttpInterceptor {
|
|
|
|
|
);
|
|
|
|
|
} else if (!error.url.includes('/auth')) {
|
|
|
|
|
this.snackBarRef = this.snackBar.open(
|
|
|
|
|
this.hasPermissionForSubscription
|
|
|
|
|
? $localize`This feature requires a subscription.`
|
|
|
|
|
: $localize`This action is not allowed.`,
|
|
|
|
|
this.hasPermissionForSubscription
|
|
|
|
|
? $localize`Upgrade Plan`
|
|
|
|
|
: undefined,
|
|
|
|
|
$localize`This action is not allowed.`,
|
|
|
|
|
undefined,
|
|
|
|
|
{ duration: 6000 }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|