2018-09-06 19:46:38 +02:00
|
|
|
<template>
|
2018-09-06 20:15:49 +02:00
|
|
|
<div class="container has-text-centered">
|
|
|
|
<div class="column is-4 is-offset-4">
|
2018-09-09 19:53:08 +02:00
|
|
|
<img src="logo-full.svg"/>
|
2018-09-06 20:15:49 +02:00
|
|
|
<h2 class="title">Login</h2>
|
|
|
|
<div class="box">
|
|
|
|
<form id="loginform" @submit.prevent="submit">
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<input type="text" class="input" name="username" placeholder="Username" v-model="credentials.username" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<input type="password" class="input" name="password" placeholder="Password" v-model="credentials.password" required>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2018-09-09 19:53:08 +02:00
|
|
|
<button type="submit" class="button is-primary" v-bind:class="{ 'is-loading': loading}">Login</button>
|
2018-09-08 22:27:13 +02:00
|
|
|
<router-link :to="{ name: 'register' }" class="button">Register</router-link>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="notification is-danger" v-if="error">
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
2018-09-06 19:46:38 +02:00
|
|
|
</div>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
2018-09-06 19:46:38 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-09-08 22:27:13 +02:00
|
|
|
import auth from '../../auth'
|
|
|
|
import router from '../../router'
|
2018-09-06 19:46:38 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
credentials: {
|
|
|
|
username: '',
|
|
|
|
password: ''
|
|
|
|
},
|
|
|
|
error: '',
|
|
|
|
loading: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
|
|
|
if (auth.user.authenticated) {
|
|
|
|
router.push({name: 'home'})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.loading = true
|
|
|
|
this.error = ''
|
|
|
|
let credentials = {
|
|
|
|
username: this.credentials.username,
|
|
|
|
password: this.credentials.password
|
|
|
|
}
|
|
|
|
|
|
|
|
auth.login(this, credentials, 'home')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
2018-09-08 22:27:13 +02:00
|
|
|
.button {
|
|
|
|
margin: 0 0.4em 0 0;
|
|
|
|
}
|
2018-09-06 19:46:38 +02:00
|
|
|
</style>
|