v0
This commit is contained in:
30
frontend/src/views/Setup.vue
Normal file
30
frontend/src/views/Setup.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2>Setup Admin Account</h2>
|
||||
<form @submit.prevent="setup">
|
||||
<input v-model="form.login" placeholder="Admin login" />
|
||||
<input v-model="form.password" type="password" placeholder="Password (min 6 chars)" />
|
||||
<button type="submit">Create Admin</button>
|
||||
</form>
|
||||
<p v-if="error">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import axios from 'axios'
|
||||
|
||||
const router = useRouter()
|
||||
const form = ref({ login: '', password: '' })
|
||||
const error = ref('')
|
||||
|
||||
async function setup() {
|
||||
try {
|
||||
await axios.post('/api/setup', form.value)
|
||||
router.push('/login')
|
||||
} catch (e) {
|
||||
error.value = e.response?.data || 'Setup failed'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user