change username to id

This commit is contained in:
jb-alvarado 2024-06-17 15:25:52 +02:00
parent e8532ba8d0
commit 61202346f7
3 changed files with 9 additions and 6 deletions

View File

@ -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 = ''

View File

@ -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
})
},

1
types/index.d.ts vendored
View File

@ -30,6 +30,7 @@ declare global {
}
interface User {
id: number
username: string
mail?: string
password?: string