User Login finished

This commit is contained in:
s-prechtl 2023-01-18 11:35:38 +01:00
parent 4f936aaa42
commit c52f6018a6
6 changed files with 311 additions and 67 deletions

View file

@ -0,0 +1,45 @@
<template>
<h2>Enter a username</h2>
<div class="form-floating mb-3">
<input type="email" class="form-control" id="floatingInput" placeholder="example name" v-model="username">
<label for="floatingInput">Username</label>
</div>
<button type="button" class="btn btn-primary" @click="setUser()">Confirm</button>
</template>
<script>
import {User} from "@/model/User";
export default {
name: "Login",
data() {
return {
username: '',
user: null,
}
},
emits: ['userChange'],
methods: {
async setUser() {
let user = await User.getByName(this.username);
if (user.errors) {
user = await User.create(this.username);
}
if (user.errors) {
console.error("Something when wrong when logging in, please contact admin!")
return;
}
if (user) {
this.user = user;
this.$emit('userChange', this.user);
}
},
}
}
</script>
<style scoped>
</style>