49 lines
No EOL
989 B
Vue
49 lines
No EOL
989 B
Vue
<template>
|
|
|
|
<div class="login">
|
|
<h1>Login</h1>
|
|
<form>
|
|
<div class="form-group">
|
|
<label for="username">Username</label>
|
|
<input v-model="username" type="text" class="form-control" id="username" placeholder="Username">
|
|
</div>
|
|
|
|
<button type="button" class="btn btn-primary" @click="login">Login</button>
|
|
</form>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import data from '@/data';
|
|
|
|
export default {
|
|
name: 'LoginVue',
|
|
props: {
|
|
redirect: {
|
|
type: String,
|
|
default: '/'
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
username: '',
|
|
}
|
|
},
|
|
methods: {
|
|
async login() {
|
|
const person = await data.login(this.username);
|
|
if (person?.id) {
|
|
this.$router.push(this.redirect);
|
|
return;
|
|
}
|
|
|
|
alert('Login failed');
|
|
}
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<style>
|
|
</style> |