From cdb7134b8043b19703b95208246babc31d369464 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 11 Nov 2019 22:14:34 +0100 Subject: [PATCH] Frontend: Use public flag to disable auth #16 Signed-off-by: Michael Mayer --- assets/resources/templates/index.tmpl | 17 +++++++++-------- docker/demo/Dockerfile | 2 +- frontend/src/app.js | 5 +++-- frontend/src/component/p-navigation.vue | 9 +++++---- frontend/tests/acceptance/navigate.js | 4 ---- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/assets/resources/templates/index.tmpl b/assets/resources/templates/index.tmpl index e0cb0aec5..8a45c6272 100644 --- a/assets/resources/templates/index.tmpl +++ b/assets/resources/templates/index.tmpl @@ -33,14 +33,15 @@ diff --git a/docker/demo/Dockerfile b/docker/demo/Dockerfile index 1d057195b..f88d91469 100644 --- a/docker/demo/Dockerfile +++ b/docker/demo/Dockerfile @@ -9,4 +9,4 @@ RUN wget -qO- https://dl.photoprism.org/fixtures/demo.tar.gz | tar xvz -C Pictur RUN photoprism import # Start PhotoPrism server -CMD photoprism start +CMD photoprism --public start diff --git a/frontend/src/app.js b/frontend/src/app.js index ea5a37176..98c3b3124 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -23,6 +23,7 @@ import { Settings } from "luxon"; const config = new Config(window.localStorage, window.appConfig); const viewer = new Viewer(); const clipboard = new Clipboard(window.localStorage, "photo_clipboard"); +const isPublic = config.getValue("public"); // Assign helpers to VueJS prototype Vue.prototype.$event = Event; @@ -69,7 +70,7 @@ const router = new Router({ router.beforeEach((to, from, next) => { if(to.matched.some(record => record.meta.admin)) { - if (Session.isAdmin()) { + if (isPublic || Session.isAdmin()) { next(); } else { next({ @@ -78,7 +79,7 @@ router.beforeEach((to, from, next) => { }); } } else if(to.matched.some(record => record.meta.auth)) { - if (Session.isUser()) { + if (isPublic || Session.isUser()) { next(); } else { next({ diff --git a/frontend/src/component/p-navigation.vue b/frontend/src/component/p-navigation.vue index 8bfa184db..0c2fbe1f5 100644 --- a/frontend/src/component/p-navigation.vue +++ b/frontend/src/component/p-navigation.vue @@ -146,7 +146,7 @@ - + camera_roll @@ -156,7 +156,7 @@ - + settings @@ -166,7 +166,7 @@ - + power_settings_new @@ -176,7 +176,7 @@ -