From eb8f702c8398b7f51461c8e967c7bc7de3c10c16 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 2 Dec 2019 09:19:34 +0100 Subject: (plugins) add helper to know if user is logged-in --- client/src/app/core/plugins/plugin.service.ts | 6 ++++++ client/src/types/register-client-option.model.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 52ba4215a..3f96ef6de 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -12,6 +12,7 @@ import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plu import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type' import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' import { HttpClient } from '@angular/common/http' +import { AuthService } from '@app/core' import { RestExtractor } from '@app/shared/rest' import { PluginType } from '@shared/models/plugins/plugin.type' import { PublicServerSetting } from '@shared/models/plugins/public-server.setting' @@ -58,6 +59,7 @@ export class PluginService implements ClientHook { constructor ( private router: Router, + private authService: AuthService, private server: ServerService, private zone: NgZone, private authHttp: HttpClient, @@ -266,6 +268,10 @@ export class PluginService implements ClientHook { .toPromise() }, + isLoggedIn: () => { + return this.authService.isLoggedIn() + }, + translate: (value: string) => { return this.translationsObservable .pipe(map(allTranslations => allTranslations[npmName])) diff --git a/client/src/types/register-client-option.model.ts b/client/src/types/register-client-option.model.ts index 243d74dea..638b08653 100644 --- a/client/src/types/register-client-option.model.ts +++ b/client/src/types/register-client-option.model.ts @@ -9,6 +9,8 @@ export type RegisterClientOptions = { export type RegisterClientHelpers = { getBaseStaticRoute: () => string + isLoggedIn: () => boolean + getSettings: () => Promise<{ [ name: string ]: string }> translate: (toTranslate: string) => Promise -- cgit v1.2.3