diff --git a/src/components/chat/ChatRenderer.vue b/src/components/chat/ChatRenderer.vue new file mode 100644 index 0000000..a2d7d9e --- /dev/null +++ b/src/components/chat/ChatRenderer.vue @@ -0,0 +1,23 @@ + + + diff --git a/src/components/chat/ChatView.vue b/src/components/chat/ChatView.vue new file mode 100644 index 0000000..cd95367 --- /dev/null +++ b/src/components/chat/ChatView.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/pages/StudentModePage.vue b/src/pages/StudentModePage.vue new file mode 100644 index 0000000..628bd24 --- /dev/null +++ b/src/pages/StudentModePage.vue @@ -0,0 +1,11 @@ + + + diff --git a/src/router/index.ts b/src/router/index.ts index 999b8b5..ed2b9c6 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,6 +2,9 @@ import { createRouter, createWebHistory } from 'vue-router'; +import { + auth +} from '@janishutz/oidc-login-sdk-browser'; import { useAuthStore } from '@/stores/authstore'; @@ -26,17 +29,43 @@ const router = createRouter( { 'title': 'App', 'auth': true } + }, + { + 'path': '/techtree', + 'name': 'techtree', + 'component': () => import( '@/pages/TechTreePage.vue' ), + 'meta': { + 'title': 'Tech Tree', + 'auth': true + } + }, + { + 'path': '/chat/:id?', + 'name': 'chat', + 'component': () => import( '@/pages/ChatPage.vue' ), + 'meta': { + 'title': 'Chat', + 'auth': true + } } ] } ); -router.beforeEach( to => { +router.beforeEach( async to => { const store = useAuthStore(); if ( to.meta.auth && !store.isAuth ) { - return { - 'name': 'home' - }; + try { + store.isAuth = await auth.check(); + } catch { + store.isAuth = false; + } + + if ( !store.isAuth ) { + return { + 'name': 'home' + }; + } } else if ( to.name === 'home' && store.isAuth ) { return { 'name': 'app' diff --git a/src/ts/types/chat.d.ts b/src/ts/types/chat.d.ts new file mode 100644 index 0000000..ef0a7ca --- /dev/null +++ b/src/ts/types/chat.d.ts @@ -0,0 +1,4 @@ +export interface ChatMessagePair { + 'question': string; + 'response': string; +}