feat: setup game and create admin user

This commit is contained in:
Settel 2023-06-03 23:05:06 +02:00
parent 846f137b7a
commit a78ed70f05
2 changed files with 14 additions and 4 deletions

View File

@ -15,7 +15,7 @@
<div class="page-setup__auth-message">{{ $t('remember-and-log-in') }}</div> <div class="page-setup__auth-message">{{ $t('remember-and-log-in') }}</div>
<template v-slot:footer> <template v-slot:footer>
<div class="page-setup__cta"> <div class="page-setup__cta">
<Button @click="createAdminAccount">{{ $t('complete-setup') }}</Button> <Button @click="createAdminAccount" :disabled="saveInProgress">{{ $t('complete-setup') }}</Button>
</div> </div>
</template> </template>
</ModalDialog> </ModalDialog>
@ -43,6 +43,7 @@ const { $t } = useI18n({
await useAuth().authenticateAndLoadUserInfo(['setup']) await useAuth().authenticateAndLoadUserInfo(['setup'])
const showAdminAccountCreatedDialog = ref(false) const showAdminAccountCreatedDialog = ref(false)
const saveInProgress = ref(false)
const authcode = ref('000000') const authcode = ref('000000')
const openModal = () => { const openModal = () => {
authcode.value = '' authcode.value = ''
@ -50,10 +51,15 @@ const openModal = () => {
authcode.value += '' + Math.floor(Math.floor(Math.random() * 10000) / 100) % 10 authcode.value += '' + Math.floor(Math.floor(Math.random() * 10000) / 100) % 10
} }
showAdminAccountCreatedDialog.value = true showAdminAccountCreatedDialog.value = true
saveInProgress.value = false
} }
const createAdminAccount = () => { const createAdminAccount = async () => {
useEngine().setupApp(authcode.value) saveInProgress.value = true
await useEngine().setupApp(authcode.value)
saveInProgress.value = false
showAdminAccountCreatedDialog.value = false
document.location.pathname = "/"
} }
</script> </script>

View File

@ -32,6 +32,10 @@ func (app *Application) createUser(gm *game.Game, name, role, authcode string) (
return "", err return "", err
} }
app.users[newUser.GetId()] = newUser app.users[newUser.GetId()] = newUser
gm.AddPlayer(newUser)
if gm != nil {
gm.AddPlayer(newUser)
}
return newUser.GetId(), nil return newUser.GetId(), nil
} }