From 61202346f75c9e6c01353f0161bd1f61dd1a5ee1 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 17 Jun 2024 15:25:52 +0200 Subject: [PATCH] change username to id --- components/ConfigUser.vue | 10 ++++++---- stores/config.ts | 4 ++-- types/index.d.ts | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/ConfigUser.vue b/components/ConfigUser.vue index b949d3a7..4a05a89b 100644 --- a/components/ConfigUser.vue +++ b/components/ConfigUser.vue @@ -103,13 +103,14 @@ const authStore = useAuth() const configStore = useConfig() const indexStore = useIndex() -const selected = ref(null as null | string) +const selected = ref(null as null | number) const users = ref([] as User[]) const showUserModal = ref(false) const newPass = ref('') const confirmPass = ref('') const user = ref({ + id: 0, username: '', mail: '', password: '', @@ -144,8 +145,8 @@ function onChange(event: any) { async function getUserConfig() { let selectUser = configStore.currentUser - if (user.value.username) { - selectUser = user.value.username.toString() + if (user.value.id) { + selectUser = user.value.id } else if (selected.value) { selectUser = selected.value } @@ -160,7 +161,7 @@ async function getUserConfig() { } async function deleteUser() { - if (configStore.configUser.username === configStore.currentUser) { + if (configStore.configUser.id === configStore.currentUser) { indexStore.msgAlert('error', t('user.deleteNotPossible'), 2) } else { await fetch(`/api/user/${configStore.configUser.username}`, { @@ -180,6 +181,7 @@ async function deleteUser() { } function clearUser() { + user.value.id = 0 user.value.username = '' user.value.mail = '' user.value.password = '' diff --git a/stores/config.ts b/stores/config.ts index 05109ed6..40d0f0b6 100644 --- a/stores/config.ts +++ b/stores/config.ts @@ -10,7 +10,7 @@ export const useConfig = defineStore('config', { configChannelRaw: [] as GuiConfig[], playlistLength: 86400.0, playout: {} as any, - currentUser: '', + currentUser: 0, configUser: {} as User, utcOffset: 0, onetimeInfo: true, @@ -172,7 +172,7 @@ export const useConfig = defineStore('config', { }) .then((response) => response.json()) .then((data) => { - this.currentUser = data.username + this.currentUser = data.id this.configUser = data }) }, diff --git a/types/index.d.ts b/types/index.d.ts index 0f7af7c8..69fae5c8 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -30,6 +30,7 @@ declare global { } interface User { + id: number username: string mail?: string password?: string