diff --git a/package-lock.json b/package-lock.json index f9b9fe1..cf81486 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "4.0.0", "dependencies": { "@primevue/themes": "^4.0.0", + "@websanova/vue-auth": "^4.2.1", "axios": "^1.7.2", "chart.js": "3.3.2", "moment": "^2.30.1", @@ -16,6 +17,7 @@ "primevue": "^4.0.0", "prismjs": "^1.29.0", "vue": "^3.4.34", + "vue-authenticate-2": "^2.2.0", "vue-router": "^4.4.0" }, "devDependencies": { @@ -924,7 +926,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -1123,6 +1124,11 @@ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.34.tgz", "integrity": "sha512-x5LmiRLpRsd9KTjAB8MPKf0CDPMcuItjP0gbNqFCIgL1I8iYp4zglhj9w9FPCdIbHG2M91RVeIbArFfFTz9I3A==" }, + "node_modules/@websanova/vue-auth": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@websanova/vue-auth/-/vue-auth-4.2.1.tgz", + "integrity": "sha512-gc4WL3WzJMkj3wZmrBAP7U7WBAcVY0/a/YhCzMVR/iA1u/8QJlugq/320CRRbZ0Acz+qbGPhdm07IRE3U053yg==" + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -3783,6 +3789,18 @@ } } }, + "node_modules/vue-authenticate-2": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vue-authenticate-2/-/vue-authenticate-2-2.2.0.tgz", + "integrity": "sha512-4jk9Wv/bV6Bfk6LWQp5WESCe6hxkBrCQThFYqkg9F70q6auEDcdwzo2cVYWPFTwQE5UFX8C9MJUC2Wx6OYwdhw==", + "optionalDependencies": { + "@rollup/rollup-linux-x64-gnu": "^4.9.5" + }, + "peerDependencies": { + "axios": "^1.6.7", + "vue": "^3.4.21" + } + }, "node_modules/vue-eslint-parser": { "version": "9.4.3", "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-9.4.3.tgz", diff --git a/package.json b/package.json index db99a80..1f38e8b 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,15 @@ }, "dependencies": { "@primevue/themes": "^4.0.0", + "@websanova/vue-auth": "^4.2.1", "axios": "^1.7.2", "chart.js": "3.3.2", "moment": "^2.30.1", "primeicons": "^6.0.1", "primevue": "^4.0.0", "vue": "^3.4.34", + "prismjs": "^1.29.0", + "vue-authenticate-2": "^2.2.0", "vue-router": "^4.4.0" }, "devDependencies": { diff --git a/src/layout/AppProfileMenu.vue b/src/layout/AppProfileMenu.vue new file mode 100644 index 0000000..4890963 --- /dev/null +++ b/src/layout/AppProfileMenu.vue @@ -0,0 +1,18 @@ + + + + + + Welcome + + {{ auth.user().name + " " + auth.user().surname }} + Logout + + + \ No newline at end of file diff --git a/src/layout/AppTopbar.vue b/src/layout/AppTopbar.vue index e52fb88..c87dce4 100644 --- a/src/layout/AppTopbar.vue +++ b/src/layout/AppTopbar.vue @@ -3,6 +3,9 @@ import { useLayout } from '@/layout/composables/layout'; import AppConfigurator from './AppConfigurator.vue'; const { onMenuToggle, toggleDarkMode, isDarkTheme } = useLayout(); +import { useAuth } from '@websanova/vue-auth/src/v3.js'; +import AppProfileMenu from './AppProfileMenu.vue'; +const auth = useAuth(); @@ -10,20 +13,16 @@ const { onMenuToggle, toggleDarkMode, isDarkTheme } = useLayout(); - + fill="var(--primary-color)" /> - + + fill="var(--primary-color)" mask="url(#path-2-inside-1)" /> APOLLO @@ -42,36 +41,29 @@ const { onMenuToggle, toggleDarkMode, isDarkTheme } = useLayout(); + type="button" class="layout-topbar-action layout-topbar-action-highlight"> - + - - - Calendar - - - - Messages - - + + - Profile + + + diff --git a/src/main.js b/src/main.js index 2a2e682..22b10db 100644 --- a/src/main.js +++ b/src/main.js @@ -11,10 +11,41 @@ import BlockViewer from '@/components/BlockViewer.vue'; import '@/assets/styles.scss'; import '@/assets/tailwind.css'; +import axios from 'axios'; + +import { createAuth } from '@websanova/vue-auth'; +import driverAuthBearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm.js'; +import driverHttpAxios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm.js'; +import driverRouterVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm.js'; + + +var auth = createAuth({ + plugins: { + http: axios, + router: router + }, + drivers: { + http: driverHttpAxios, + auth: driverAuthBearer, + router: driverRouterVueRouter + }, + options:{ + notFoundRedirect: '/auth/login', + authRedirect: '/auth/login', + loginData: {url: 'api/auth/login', method: 'POST', redirect: '/'}, + fetchData: {url: 'api/auth/fetch-user', method: 'GET', enabled: true}, + refreshData: {url: 'api/auth/refresh-token', method: 'GET', enabled: true} + } +}); + + +axios.defaults.baseURL ='http://localhost:8082' // import.meta.env.VITE_BACKEND_URL; +console.log(import.meta.env.VITE_BACKEND_URL); const app = createApp(App); app.use(router); +app.use(auth); app.use(PrimeVue, { theme: { preset: Aura, diff --git a/src/router/index.js b/src/router/index.js index 210ce1b..c2e7aec 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,32 +2,38 @@ import AppLayout from '@/layout/AppLayout.vue'; import { createRouter, createWebHistory } from 'vue-router'; const router = createRouter({ - history: createWebHistory(), - routes: [ + history: createWebHistory(), + routes: [ + { + path: '/', + component: AppLayout, + meta: { + auth: true + }, + children: [ { - path: '/', - component: AppLayout, - children: [ - { - path: '/', - name: 'dashboard', - component: () => import('@/views/Dashboard.vue') - }, - { - path: '/ksdocuments', - children: [ - {path: '', name: 'ks-document', component: () => import('@/views/pages/KsDocuments.vue')}, - {path: 'new', name: 'ks-document-new', component: () => import('@/views/pages/KsNewDocumentForm.vue')}, - //{path: ':id', name: 'ks-document-edit', component: () => import('@/views/pages/KsEditDocumentForm.vue')}, - {path: '/ks_similarity_search', name: 'ks_similarity_search', component: () => import('@/views/pages/KsSimilaritySearch.vue')}, - {path: '/ks_vector_data', name: 'ks_vector_data', component: () => import('@/views/pages/KsVectorData.vue')} - - ] - - }, - ] - } - ] + path: '/', + name: 'dashboard', + component: () => import('@/views/Dashboard.vue') + }, + { + path: '/ksdocuments', + children: [ + {path: '', name: 'ks-document', component: () => import('@/views/pages/KsDocuments.vue')}, + {path: 'new', name: 'ks-document-new', component: () => import('@/views/pages/KsNewDocumentForm.vue')}, + //{path: ':id', name: 'ks-document-edit', component: () => import('@/views/pages/KsEditDocumentForm.vue')}, + {path: '/ks_similarity_search', name: 'ks_similarity_search', component: () => import('@/views/pages/KsSimilaritySearch.vue')}, + {path: '/ks_vector_data', name: 'ks_vector_data', component: () => import('@/views/pages/KsVectorData.vue')} + ] + }, + ] + }, + { + path: '/auth/login', + name: 'login', + component: () => import('@/views/pages/auth/Login.vue') + }, + ] }); export default router; diff --git a/src/views/pages/auth/Login.vue b/src/views/pages/auth/Login.vue index a665c95..1d75e71 100644 --- a/src/views/pages/auth/Login.vue +++ b/src/views/pages/auth/Login.vue @@ -1,59 +1,81 @@ - - - - - - - - Welcome, Isabel! - Sign in to continue - + + - - Email - + + + + Welcome to Apollo- The Knowledge + Source + - Password - + + Username + - - - - Remember me - - Forgot password? - - - - - + Password + + + + + + +