feat: setup game and create admin user
This commit is contained in:
parent
846f137b7a
commit
a78ed70f05
@ -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>
|
||||
|
||||
|
@ -32,6 +32,10 @@ func (app *Application) createUser(gm *game.Game, name, role, authcode string) (
|
||||
return "", err
|
||||
}
|
||||
app.users[newUser.GetId()] = newUser
|
||||
|
||||
if gm != nil {
|
||||
gm.AddPlayer(newUser)
|
||||
}
|
||||
|
||||
return newUser.GetId(), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user