1
0
Fork 0

(plugins) add helper to know if user is logged-in

This commit is contained in:
Rigel Kent 2019-12-02 09:19:34 +01:00 committed by Chocobozzz
parent a3ce4ae847
commit eb8f702c83
2 changed files with 8 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plu
import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type' import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { AuthService } from '@app/core'
import { RestExtractor } from '@app/shared/rest' import { RestExtractor } from '@app/shared/rest'
import { PluginType } from '@shared/models/plugins/plugin.type' import { PluginType } from '@shared/models/plugins/plugin.type'
import { PublicServerSetting } from '@shared/models/plugins/public-server.setting' import { PublicServerSetting } from '@shared/models/plugins/public-server.setting'
@ -58,6 +59,7 @@ export class PluginService implements ClientHook {
constructor ( constructor (
private router: Router, private router: Router,
private authService: AuthService,
private server: ServerService, private server: ServerService,
private zone: NgZone, private zone: NgZone,
private authHttp: HttpClient, private authHttp: HttpClient,
@ -266,6 +268,10 @@ export class PluginService implements ClientHook {
.toPromise() .toPromise()
}, },
isLoggedIn: () => {
return this.authService.isLoggedIn()
},
translate: (value: string) => { translate: (value: string) => {
return this.translationsObservable return this.translationsObservable
.pipe(map(allTranslations => allTranslations[npmName])) .pipe(map(allTranslations => allTranslations[npmName]))

View file

@ -9,6 +9,8 @@ export type RegisterClientOptions = {
export type RegisterClientHelpers = { export type RegisterClientHelpers = {
getBaseStaticRoute: () => string getBaseStaticRoute: () => string
isLoggedIn: () => boolean
getSettings: () => Promise<{ [ name: string ]: string }> getSettings: () => Promise<{ [ name: string ]: string }>
translate: (toTranslate: string) => Promise<string> translate: (toTranslate: string) => Promise<string>