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

View File

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