From 7584c774bb10c812b652b822176fe08a4f63366d Mon Sep 17 00:00:00 2001 From: nhas Date: Thu, 21 Nov 2024 20:35:03 +1300 Subject: [PATCH] Add registration token functionality, remove unused vue pages --- adminui2/src/App.vue | 3 +- adminui2/src/api/registration_tokens.ts | 13 +- adminui2/src/api/types.ts | 2 +- adminui2/src/components/ConfirmModal.vue | 8 +- adminui2/src/layouts/default.vue | 2 +- adminui2/src/pages/Agents.vue | 149 -------- adminui2/src/pages/AttackTemplates.vue | 148 -------- .../src/pages/{admin => }/Configuration.vue | 0 adminui2/src/pages/HashSearch.vue | 90 ----- adminui2/src/pages/Listfiles.vue | 189 ---------- adminui2/src/pages/RegistrationTokens.vue | 221 ++++++++++++ adminui2/src/pages/{admin => }/Users.vue | 0 adminui2/src/pages/Utilisation.vue | 56 --- adminui2/src/pages/Wizard.vue | 18 - adminui2/src/pages/admin/Agents.vue | 330 ------------------ adminui2/src/router/index.ts | 4 +- adminui2/src/stores/registration_tokens.ts | 4 +- 17 files changed, 241 insertions(+), 996 deletions(-) delete mode 100644 adminui2/src/pages/Agents.vue delete mode 100644 adminui2/src/pages/AttackTemplates.vue rename adminui2/src/pages/{admin => }/Configuration.vue (100%) delete mode 100644 adminui2/src/pages/HashSearch.vue delete mode 100644 adminui2/src/pages/Listfiles.vue create mode 100644 adminui2/src/pages/RegistrationTokens.vue rename adminui2/src/pages/{admin => }/Users.vue (100%) delete mode 100644 adminui2/src/pages/Utilisation.vue delete mode 100644 adminui2/src/pages/Wizard.vue delete mode 100644 adminui2/src/pages/admin/Agents.vue diff --git a/adminui2/src/App.vue b/adminui2/src/App.vue index ed2a4cd2..bb9c0d8e 100644 --- a/adminui2/src/App.vue +++ b/adminui2/src/App.vue @@ -13,7 +13,7 @@ const authStore = useAuthStore() const devicesStore = useDevicesStore() const usersStore = useUsersStore() -const { hasCompletedAuth, hasTriedAuth, loggedInUser, isLoggedIn } = storeToRefs(authStore) +const { hasCompletedAuth, hasTriedAuth, isLoggedIn } = storeToRefs(authStore) const toast = useToast() @@ -29,7 +29,6 @@ onMounted(async () => { watch(hasCompletedAuth, (newHasCompletedAuth, prevHasCompletedAuth) => { if (newHasCompletedAuth && !prevHasCompletedAuth) { - toast.success(`Welcome ${loggedInUser.value?.username}`) devicesStore.load(true) usersStore.load(true) } diff --git a/adminui2/src/api/registration_tokens.ts b/adminui2/src/api/registration_tokens.ts index 11e02de8..be2dc726 100644 --- a/adminui2/src/api/registration_tokens.ts +++ b/adminui2/src/api/registration_tokens.ts @@ -1,7 +1,16 @@ -import type { RegistrationToken } from './types' +import type { GenericResponseDTO, RegistrationTokenRequestDTO } from './types' import { client } from '.' -export function getAllRegistrationTokens(): Promise { +export function getAllRegistrationTokens(): Promise { return client.get('/api/management/registration_tokens').then(res => res.data) } + + +export function createRegistrationToken(token: RegistrationTokenRequestDTO): Promise { + return client.post('/api/management/registration_tokens', token).then(res => res.data) +} + +export function deleteRegistrationTokens(tokens: string[]): Promise { + return client.delete('/api/management/registration_tokens', {data: tokens}).then(res => res.data) +} diff --git a/adminui2/src/api/types.ts b/adminui2/src/api/types.ts index 1603600b..8df90b43 100644 --- a/adminui2/src/api/types.ts +++ b/adminui2/src/api/types.ts @@ -5,7 +5,7 @@ export interface RuleDTO { deny_routes: string[] } -export interface RegistrationToken { +export interface RegistrationTokenRequestDTO { token: string username: string groups: string[] diff --git a/adminui2/src/components/ConfirmModal.vue b/adminui2/src/components/ConfirmModal.vue index 0bf3e97a..7cda73ec 100644 --- a/adminui2/src/components/ConfirmModal.vue +++ b/adminui2/src/components/ConfirmModal.vue @@ -22,8 +22,8 @@ function confirm() {