From e9468c154a0c775838458a1f3987f26cbe07e574 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sat, 5 Sep 2020 16:06:11 +0200 Subject: [PATCH] Hiding faces for guest users (sharing link). Fixes: #149 --- src/backend/routes/PersonRouter.ts | 2 +- src/common/config/public/ClientConfig.ts | 2 ++ src/frontend/app/ui/frame/frame.component.html | 2 +- src/frontend/app/ui/frame/frame.component.ts | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/routes/PersonRouter.ts b/src/backend/routes/PersonRouter.ts index 456ac890..ecd17070 100644 --- a/src/backend/routes/PersonRouter.ts +++ b/src/backend/routes/PersonRouter.ts @@ -33,7 +33,7 @@ export class PersonRouter { app.get(['/api/person'], // common part AuthenticationMWs.authenticate, - AuthenticationMWs.authorise(UserRoles.User), + AuthenticationMWs.authorise(Config.Client.Faces.readAccessMinRole), VersionMWs.injectGalleryVersion, // specific part diff --git a/src/common/config/public/ClientConfig.ts b/src/common/config/public/ClientConfig.ts index d1da3ac1..8c320904 100644 --- a/src/common/config/public/ClientConfig.ts +++ b/src/common/config/public/ClientConfig.ts @@ -149,6 +149,8 @@ export module ClientConfig { keywordsToPersons: boolean = true; @ConfigProperty({type: UserRoles}) writeAccessMinRole: UserRoles = UserRoles.Admin; + @ConfigProperty({type: UserRoles}) + readAccessMinRole: UserRoles = UserRoles.User; } @SubConfigClass() diff --git a/src/frontend/app/ui/frame/frame.component.html b/src/frontend/app/ui/frame/frame.component.html index c507204f..ce656e54 100644 --- a/src/frontend/app/ui/frame/frame.component.html +++ b/src/frontend/app/ui/frame/frame.component.html @@ -17,7 +17,7 @@ [routerLink]="['/gallery']" [queryParams]="queryService.getParams()" i18n>Gallery - diff --git a/src/frontend/app/ui/frame/frame.component.ts b/src/frontend/app/ui/frame/frame.component.ts index 3275d47f..65521743 100644 --- a/src/frontend/app/ui/frame/frame.component.ts +++ b/src/frontend/app/ui/frame/frame.component.ts @@ -20,7 +20,6 @@ export class FrameComponent { public readonly authenticationRequired = Config.Client.authenticationRequired; public readonly title = Config.Client.applicationTitle; collapsed = true; - facesEnabled = Config.Client.Faces.enabled; constructor(private _authService: AuthenticationService, public notificationService: NotificationService, @@ -33,6 +32,10 @@ export class FrameComponent { return this.user.value && this.user.value.role >= UserRoles.Admin; } + isFacesAvailable() { + return Config.Client.Faces.enabled && this.user.value && this.user.value.role >= Config.Client.Faces.readAccessMinRole; + } + logout() { this._authService.logout();