2018-09-06 19:46:38 +02:00
|
|
|
<template>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div>
|
2019-10-19 16:27:56 +02:00
|
|
|
<h2 class="title has-text-centered">Register</h2>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="box">
|
2020-09-05 22:35:52 +02:00
|
|
|
<form @submit.prevent="submit" id="registerform">
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="field">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="username">Username</label>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="username"
|
|
|
|
name="username"
|
|
|
|
placeholder="e.g. frederick"
|
|
|
|
required
|
|
|
|
type="text"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="username"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-focus
|
|
|
|
v-model="credentials.username"/>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="email">E-mail address</label>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="email"
|
|
|
|
name="email"
|
|
|
|
placeholder="e.g. frederic@vikunja.io"
|
|
|
|
required
|
|
|
|
type="email"
|
|
|
|
v-model="credentials.email"/>
|
2018-09-08 22:27:13 +02:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="password1">Password</label>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password1"
|
|
|
|
name="password1"
|
|
|
|
placeholder="e.g. ••••••••••••"
|
|
|
|
required
|
|
|
|
type="password"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="new-password"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-model="credentials.password"/>
|
2018-09-08 22:27:13 +02:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
<div class="field">
|
2019-10-19 16:27:56 +02:00
|
|
|
<label class="label" for="password2">Retype your password</label>
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="control">
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
|
|
|
class="input"
|
|
|
|
id="password2"
|
|
|
|
name="password2"
|
|
|
|
placeholder="e.g. ••••••••••••"
|
|
|
|
required
|
|
|
|
type="password"
|
2020-11-02 23:41:18 +01:00
|
|
|
autocomplete="new-password"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-model="credentials.password2"/>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
2018-09-06 20:15:49 +02:00
|
|
|
|
2018-11-01 21:34:29 +00:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control">
|
2021-01-17 17:57:57 +00:00
|
|
|
<x-button
|
|
|
|
:loading="loading"
|
|
|
|
id="register-submit"
|
|
|
|
@click="submit"
|
|
|
|
class="mr-2"
|
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
Register
|
2021-01-17 17:57:57 +00:00
|
|
|
</x-button>
|
|
|
|
<x-button :to="{ name: 'user.login' }" type="secondary">Login</x-button>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
<div class="notification is-info" v-if="loading">
|
|
|
|
Loading...
|
|
|
|
</div>
|
2020-05-08 18:43:51 +00:00
|
|
|
<div class="notification is-danger" v-if="errorMessage !== ''">
|
|
|
|
{{ errorMessage }}
|
2018-11-01 21:34:29 +00:00
|
|
|
</div>
|
|
|
|
</form>
|
2020-07-18 21:39:30 +02:00
|
|
|
<legal/>
|
2018-09-06 20:15:49 +02:00
|
|
|
</div>
|
2018-09-06 19:46:38 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import router from '../../router'
|
|
|
|
import {mapState} from 'vuex'
|
|
|
|
import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types'
|
|
|
|
import Legal from '../../components/misc/legal'
|
2018-09-06 19:46:38 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Legal,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
credentials: {
|
|
|
|
username: '',
|
|
|
|
email: '',
|
|
|
|
password: '',
|
|
|
|
password2: '',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
|
|
|
if (this.authenticated) {
|
|
|
|
router.push({name: 'home'})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setTitle('Register')
|
|
|
|
},
|
|
|
|
computed: mapState({
|
|
|
|
authenticated: state => state.auth.authenticated,
|
|
|
|
loading: LOADING,
|
|
|
|
errorMessage: ERROR_MESSAGE,
|
|
|
|
}),
|
|
|
|
methods: {
|
|
|
|
submit() {
|
|
|
|
this.$store.commit(LOADING, true)
|
|
|
|
this.$store.commit(ERROR_MESSAGE, '')
|
2018-09-08 22:27:13 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
if (this.credentials.password2 !== this.credentials.password) {
|
|
|
|
this.$store.commit(ERROR_MESSAGE, 'Passwords don\'t match.')
|
|
|
|
this.$store.commit(LOADING, false)
|
|
|
|
return
|
|
|
|
}
|
2018-09-06 19:46:38 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
const credentials = {
|
|
|
|
username: this.credentials.username,
|
|
|
|
email: this.credentials.email,
|
|
|
|
password: this.credentials.password,
|
2019-03-02 10:25:10 +00:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
|
|
|
|
this.$store.dispatch('auth/register', credentials)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2018-09-06 19:46:38 +02:00
|
|
|
</script>
|