diff --git a/src/client.py b/src/client.py index a93a4a8..72c0409 100644 --- a/src/client.py +++ b/src/client.py @@ -101,4 +101,9 @@ def createClientBlueprint(wireguardConfigurations: dict[WireguardConfiguration], def ClientAPI_Configurations(): return ResponseObject(True, data=DashboardClients.GetClientAssignedPeers(session['ClientID'])) + @client.get(f'{prefix}/api/settings/getClientProfile') + @login_required + def ClientAPI_Settings_GetClientProfile(): + return ResponseObject(data=DashboardClients.GetClientProfile(session['ClientID'])) + return client \ No newline at end of file diff --git a/src/modules/DashboardClients.py b/src/modules/DashboardClients.py index 2d0bdc5..8658c5d 100644 --- a/src/modules/DashboardClients.py +++ b/src/modules/DashboardClients.py @@ -63,7 +63,9 @@ class DashboardClients: def GetClientProfile(self, ClientID): with self.engine.connect() as conn: return dict(conn.execute( - self.dashboardClientsInfoTable.select().where( + db.select( + *[c for c in self.dashboardClientsInfoTable.c if c.name != 'ClientID'] + ).where( self.dashboardClientsInfoTable.c.ClientID == ClientID ) ).mappings().fetchone()) diff --git a/src/static/client/src/components/Settings/profile.vue b/src/static/client/src/components/Settings/profile.vue new file mode 100644 index 0000000..5b32f8b --- /dev/null +++ b/src/static/client/src/components/Settings/profile.vue @@ -0,0 +1,72 @@ + + + + + \ No newline at end of file diff --git a/src/static/client/src/components/SignIn/totpForm.vue b/src/static/client/src/components/SignIn/totpForm.vue index 7801fb2..5824c4b 100644 --- a/src/static/client/src/components/SignIn/totpForm.vue +++ b/src/static/client/src/components/SignIn/totpForm.vue @@ -56,7 +56,7 @@ const verify = async (e) => { loading.value = false if (data){ if (data.status){ - console.log(data.data) + store.clientProfile = data.data; router.push('/') }else{ store.newNotification(data.message, "danger") diff --git a/src/static/client/src/router/router.js b/src/static/client/src/router/router.js index b12939c..6e4403c 100644 --- a/src/static/client/src/router/router.js +++ b/src/static/client/src/router/router.js @@ -5,6 +5,7 @@ import SignUp from "@/views/signup.vue"; import axios from "axios"; import {axiosGet, requestURl} from "@/utilities/request.js"; import {clientStore} from "@/stores/clientStore.js"; +import Settings from "@/views/settings.vue"; const router = createRouter({ history: createWebHashHistory(), @@ -17,6 +18,14 @@ const router = createRouter({ }, name: "Home" }, + { + path: '/settings', + component: Settings, + meta: { + auth: true + }, + name: "Settings" + }, { path: '/signin', component: SignIn, @@ -35,10 +44,7 @@ const router = createRouter({ }) router.beforeEach(async (to, from, next) => { const store = clientStore() - if (to.path === '/signout'){ - - await axios.get(requestURl('/api/signout')).then(() => { next('/signin') }).catch(() => { @@ -58,8 +64,6 @@ router.beforeEach(async (to, from, next) => { next() } } - - }) router.afterEach((to, from, next) => { diff --git a/src/static/client/src/stores/clientStore.js b/src/static/client/src/stores/clientStore.js index ebf8c09..0704b90 100644 --- a/src/static/client/src/stores/clientStore.js +++ b/src/static/client/src/stores/clientStore.js @@ -4,35 +4,40 @@ import {v4} from "uuid" import dayjs from "dayjs"; import {axiosGet} from "@/utilities/request.js"; - -export const clientStore = defineStore('clientStore', () => { - const notifications = ref([]) - const configurations = ref([]) - const clientProfile = reactive({ - Email: "", - Profile: {} - }) - - - function newNotification(content, status) { - notifications.value.push({ - id: v4().toString(), - status: status, - content: content, - time: dayjs(), - show: true - }) - } - - async function getConfigurations(){ - const data = await axiosGet("/api/configurations") - if (data){ - configurations.value = data.data - }else{ - newNotification("Failed to fetch configurations", "danger") +export const clientStore = defineStore('clientStore', { + state: () => ({ + notifications: [], + configurations: [], + clientProfile: { + Email: "", + Profile: {} + } + }), + actions: { + newNotification(content, status){ + this.notifications.push({ + id: v4().toString(), + status: status, + content: content, + time: dayjs(), + show: true + }) + }, + async getClientProfile(){ + const data = await axiosGet('/api/settings/getClientProfile') + if (data){ + this.clientProfile.Profile = data.data + }else{ + this.newNotification("Failed to fetch client profile", "danger") + } + }, + async getConfigurations(){ + const data = await axiosGet("/api/configurations") + if (data){ + this.configurations = data.data + }else{ + this.newNotification("Failed to fetch configurations", "danger") + } } } - return { - notifications, newNotification, getConfigurations, configurations, clientProfile - } }) \ No newline at end of file diff --git a/src/static/client/src/views/index.vue b/src/static/client/src/views/index.vue index ea1b410..868e110 100644 --- a/src/static/client/src/views/index.vue +++ b/src/static/client/src/views/index.vue @@ -29,10 +29,10 @@ onMounted(async () => { WGDashboard Client