diff --git a/front/src/AppNavBar.vue b/front/src/AppNavBar.vue index b74c5e3..bbae086 100644 --- a/front/src/AppNavBar.vue +++ b/front/src/AppNavBar.vue @@ -4,7 +4,7 @@ import NavBarSearch from './NavBarSearch.vue' import BarcodeModal from './BarcodeModal.vue' import { useAuthStore } from './auth.store.js' - import { getAppInfo } from './api.js' + import { getAppInfo, postLogin } from './api.js' import { onMounted } from 'vue' const authStore = useAuthStore(); @@ -21,8 +21,23 @@ const appInfo = ref(null); const appInfoErr = ref(null); + async function logInIfDemoMode(demoMode) { + if (!demoMode) { + return; + } + + const demouser = ref({ + username: "demo", + password: "" + }); + const res = await postLogin(demouser) + const json = await res.json(); + await useAuthStore().login({username: demouser.value.username, token: json["token"]}) + } + onMounted(() => { - getAppInfo(appInfo, appInfoErr); + getAppInfo(appInfo, appInfoErr) + .then(() => logInIfDemoMode(appInfo.value.demoMode)); }) @@ -62,7 +77,7 @@ {{ $t('navbar.addbook')}} -