Created signup form
This commit is contained in:
@@ -13,7 +13,7 @@ const jwt = inject<TokenInjectType>('jwt') as TokenInjectType;
|
||||
|
||||
async function login() {
|
||||
if (username.value === '' || password.value === '') {
|
||||
error.value = 'Username and/or Password missing';
|
||||
error.value = 'Email and/or Password missing';
|
||||
return;
|
||||
}
|
||||
const res = await auth_login(username.value, password.value);
|
||||
@@ -38,6 +38,7 @@ async function login() {
|
||||
<input type="email" placeholder="Email" v-model="username" />
|
||||
<input type="password" placeholder="Password" v-model="password" />
|
||||
<button @click="login()">Login</button>
|
||||
<router-link to="signup">Signup instead?</router-link>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
35
frontend/src/views/SignupView.vue
Normal file
35
frontend/src/views/SignupView.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { auth_signup, isErrorResponse } from '@/api';
|
||||
|
||||
let username = ref('');
|
||||
let password = ref('');
|
||||
let password2 = ref('');
|
||||
const error = ref('');
|
||||
|
||||
async function signup() {
|
||||
if (username.value === '' || password.value === '') {
|
||||
error.value = 'Email and/or Password missing';
|
||||
return;
|
||||
}
|
||||
if (password.value !== password2.value) {
|
||||
error.value = "Passwords don't match";
|
||||
return;
|
||||
}
|
||||
const res = await auth_signup(username.value, password.value);
|
||||
error.value = isErrorResponse(res)
|
||||
? 'Signup failed: ' + res.message
|
||||
: 'Signup successful, please wait till an admin unlocks your account.';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="error !== ''" v-text="error"></div>
|
||||
<input type="email" placeholder="Email" v-model="username" />
|
||||
<input type="password" placeholder="Password" v-model="password" />
|
||||
<input type="password" placeholder="Repeat password" v-model="password2" />
|
||||
<button @click="signup()">Signup</button>
|
||||
<router-link to="login">Login instead?</router-link>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user