Frontend: signup added

This commit is contained in:
2024-01-02 00:42:22 +01:00
parent cb529e47d9
commit f8559b477b
4 changed files with 318 additions and 7 deletions

View File

@ -1,5 +1,4 @@
<script setup>
import FormBase from '@/components/FormBase.vue'
import router from '@/router'
</script>

View File

@ -1,14 +1,36 @@
<script setup>
import FormBase from '@/components/FormBase.vue'
import router from '@/router'
</script>
<template>
<FormBase btn-txt="Signup" api-endpoint="/user/signup">
<form>
<label for="username">Username:</label>
<input type="text" id="username" placeholder="Username" />
<input type="text" id="username" v-model="username" placeholder="Username" />
<label for="email">Email:</label>
<input type="email" id="email" placeholder="Email" />
<input type="email" id="email" v-model="email" placeholder="Email" />
<label for="password">Password:</label>
<input type="password" id="password" placeholder="Password" />
</FormBase>
<input type="password" id="password" v-model="password" placeholder="Password" />
<button @click.prevent="formAction">Sign up</button>
</form>
</template>
<script>
import User from '@/api/user'
export default {
data() {
return {
username: '',
email: '',
password: ''
}
},
methods: {
async formAction() {
const status = await User.registerUser({ username: this.username, email: this.email, password: this.password })
if (status.code == 201) {
throw router.push('/')
}
}
}
}
</script>