(plugins) add helper to know if user is logged-in
authorRigel Kent <sendmemail@rigelk.eu>
Mon, 2 Dec 2019 08:19:34 +0000 (09:19 +0100)
committerChocobozzz <chocobozzz@framasoft.org>
Mon, 2 Dec 2019 08:19:34 +0000 (09:19 +0100)
client/src/app/core/plugins/plugin.service.ts
client/src/types/register-client-option.model.ts

index 52ba4215ab380bfd39444ebc45c1b338d773c950..3f96ef6de72bf79ca147ccc4429aacd9752c6219 100644 (file)
@@ -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]))
index 243d74dea7257a85d6a41211ba2d5277c7cc0bb1..638b086532f2d614a7608fc4b3bba0d7ee556252 100644 (file)
@@ -9,6 +9,8 @@ export type RegisterClientOptions = {
 export type RegisterClientHelpers = {
   getBaseStaticRoute: () => string
 
+  isLoggedIn: () => boolean
+
   getSettings: () => Promise<{ [ name: string ]: string }>
 
   translate: (toTranslate: string) => Promise<string>