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 configStore = useConfig()
const indexStore = useIndex() const indexStore = useIndex()
const selected = ref(null as null | string) const selected = ref(null as null | number)
const users = ref([] as User[]) const users = ref([] as User[])
const showUserModal = ref(false) const showUserModal = ref(false)
const newPass = ref('') const newPass = ref('')
const confirmPass = ref('') const confirmPass = ref('')
const user = ref({ const user = ref({
id: 0,
username: '', username: '',
mail: '', mail: '',
password: '', password: '',
@ -144,8 +145,8 @@ function onChange(event: any) {
async function getUserConfig() { async function getUserConfig() {
let selectUser = configStore.currentUser let selectUser = configStore.currentUser
if (user.value.username) { if (user.value.id) {
selectUser = user.value.username.toString() selectUser = user.value.id
} else if (selected.value) { } else if (selected.value) {
selectUser = selected.value selectUser = selected.value
} }
@ -160,7 +161,7 @@ async function getUserConfig() {
} }
async function deleteUser() { async function deleteUser() {
if (configStore.configUser.username === configStore.currentUser) { if (configStore.configUser.id === configStore.currentUser) {
indexStore.msgAlert('error', t('user.deleteNotPossible'), 2) indexStore.msgAlert('error', t('user.deleteNotPossible'), 2)
} else { } else {
await fetch(`/api/user/${configStore.configUser.username}`, { await fetch(`/api/user/${configStore.configUser.username}`, {
@ -180,6 +181,7 @@ async function deleteUser() {
} }
function clearUser() { function clearUser() {
user.value.id = 0
user.value.username = '' user.value.username = ''
user.value.mail = '' user.value.mail = ''
user.value.password = '' user.value.password = ''

View File

@ -10,7 +10,7 @@ export const useConfig = defineStore('config', {
configChannelRaw: [] as GuiConfig[], configChannelRaw: [] as GuiConfig[],
playlistLength: 86400.0, playlistLength: 86400.0,
playout: {} as any, playout: {} as any,
currentUser: '', currentUser: 0,
configUser: {} as User, configUser: {} as User,
utcOffset: 0, utcOffset: 0,
onetimeInfo: true, onetimeInfo: true,
@ -172,7 +172,7 @@ export const useConfig = defineStore('config', {
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
this.currentUser = data.username this.currentUser = data.id
this.configUser = data this.configUser = data
}) })
}, },

1
types/index.d.ts vendored
View File

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