From aa69dac418de04a8d85c28a451b1b15ebbf4e2be Mon Sep 17 00:00:00 2001 From: Angelika Schneider Date: Tue, 18 Jul 2023 11:51:47 +0200 Subject: [PATCH 1/3] Add path check for endpoint /public/certificates --- src/lib/Navigation.svelte | 1 - src/lib/orchestrator.ts | 1 + src/routes/+layout.ts | 14 +++++++++----- src/routes/public/certificates/+page.ts | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lib/Navigation.svelte b/src/lib/Navigation.svelte index e9c7bc1..19d6b0f 100644 --- a/src/lib/Navigation.svelte +++ b/src/lib/Navigation.svelte @@ -96,7 +96,6 @@ console.log($page.url); Login {/if} - Help diff --git a/src/lib/orchestrator.ts b/src/lib/orchestrator.ts index b254afc..3383b93 100644 --- a/src/lib/orchestrator.ts +++ b/src/lib/orchestrator.ts @@ -1,3 +1,4 @@ +import { error } from "@sveltejs/kit"; import type { AssessmentResult, Metric, MetricConfiguration, MetricImplementation } from "./assessment"; import { clouditorize } from './util'; diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 24ac37f..ae95cfc 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -3,7 +3,14 @@ import { getRuntimeInfo, listCatalogs, listControls, listMetrics } from "$lib/or import { metrics, controls } from "$lib/stores"; import type { LayoutLoad } from "./$types"; -export const load: LayoutLoad = async ({ fetch }) => { +export const load: LayoutLoad = async ({ fetch, url}) => { + + // If the the path '/public/certificates' was called, we return here without calling the other endpoints. + if (url.pathname == "/public/certificates") { + console.info("public certificates endpoint called: ignore furhter load functionality") + return + } + // Since we want a map for convenience, we need to use a store, rather than // exposing the metric through a layout data props. Layout data props need // to be JSON and thus, a real ES6 map cannot be used. @@ -16,7 +23,6 @@ export const load: LayoutLoad = async ({ fetch }) => { .catch(() => { // ignore, we will catch it later console.error("error getting metrics") - return }); listControls(null, null, fetch).then((list) => { @@ -25,7 +31,6 @@ export const load: LayoutLoad = async ({ fetch }) => { .catch(() => { // ignore, we will catch it later console.error("error getting controls") - return }); try { @@ -39,8 +44,7 @@ export const load: LayoutLoad = async ({ fetch }) => { } } catch (error) { console.warn("error start page load function") - return - // return redirectLogin('/cloud'); + return redirectLogin('/cloud'); } } diff --git a/src/routes/public/certificates/+page.ts b/src/routes/public/certificates/+page.ts index 46f2417..1954dde 100644 --- a/src/routes/public/certificates/+page.ts +++ b/src/routes/public/certificates/+page.ts @@ -4,7 +4,7 @@ import { redirectLogin } from '$lib/oauth'; /** * @type {import('@sveltejs/kit').PageLoad} */ -export async function load({ params, fetch }) { +export async function load({}) { return listPublicCertificates() .then((certificates) => { return { @@ -12,6 +12,7 @@ export async function load({ params, fetch }) { }; }) .catch(() => { + console.error("error listPublicCertificates") redirectLogin('/cloud'); }); } From 33196c2003ee98415188cc28f12d6384b4c8364a Mon Sep 17 00:00:00 2001 From: Angelika Schneider Date: Tue, 18 Jul 2023 12:17:48 +0200 Subject: [PATCH 2/3] Add redirect from start page to cloud page if already logged in --- src/lib/Navigation.svelte | 62 +++++++++++++++++++-------------------- src/lib/orchestrator.ts | 1 - src/routes/+layout.svelte | 2 +- src/routes/+layout.ts | 2 +- src/routes/+page.svelte | 6 ++++ 5 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/lib/Navigation.svelte b/src/lib/Navigation.svelte index 19d6b0f..a4946a2 100644 --- a/src/lib/Navigation.svelte +++ b/src/lib/Navigation.svelte @@ -18,40 +18,38 @@ function handleUpdate(event) { isOpen = event.detail.isOpen; } -let routes = [ - { - url: '/cloud', - name: 'Cloud Services' - }, - // We are hiding these paths for MEDINA, since they can be viewed on the service-specific views - // { - // url: '/discovery', - // name: 'Discovery' - // }, - // { - // url: '/assessment', - // name: 'Assessment' - // }, - { - url: '/metrics', - name: 'Metrics' - }, - { - url: '/catalogs', - name: 'Catalogues' - }, - { - url: '/certificates', - name: 'Certificates' - }, - { - name: 'Help' - } -]; +// let routes = [ +// { +// url: '/cloud', +// name: 'Cloud Services' +// }, +// // We are hiding these paths for MEDINA, since they can be viewed on the service-specific views +// // { +// // url: '/discovery', +// // name: 'Discovery' +// // }, +// // { +// // url: '/assessment', +// // name: 'Assessment' +// // }, +// { +// url: '/metrics', +// name: 'Metrics' +// }, +// { +// url: '/catalogs', +// name: 'Catalogues' +// }, +// { +// url: '/certificates', +// name: 'Certificates' +// }, +// { +// name: 'Help' +// } +// ]; let loggedIn = localStorage.token ? true : false; - -console.log($page.url); diff --git a/src/lib/orchestrator.ts b/src/lib/orchestrator.ts index 3383b93..b254afc 100644 --- a/src/lib/orchestrator.ts +++ b/src/lib/orchestrator.ts @@ -1,4 +1,3 @@ -import { error } from "@sveltejs/kit"; import type { AssessmentResult, Metric, MetricConfiguration, MetricImplementation } from "./assessment"; import { clouditorize } from './util'; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index b621869..a05b627 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -52,7 +52,7 @@ function getVersionMessage(): string {
- +