2019-04-03 00:25:12 +02:00
|
|
|
<template lang='pug'>
|
2019-06-06 23:54:32 +02:00
|
|
|
el-card
|
|
|
|
|
|
|
|
|
|
nuxt-link.float-right(to='/')
|
|
|
|
|
v-icon(name='times' color='red')
|
|
|
|
|
h5 {{$t('common.register')}}
|
|
|
|
|
|
2019-06-18 14:45:04 +02:00
|
|
|
el-form(@submit.native.prevent='register' method='POST' action='/api/user/register')
|
2019-04-26 23:14:43 +02:00
|
|
|
p(v-html="$t('register.description')")
|
2019-05-30 12:04:14 +02:00
|
|
|
el-input.mb-2(ref='email' v-model='user.email' type='email' required
|
2019-06-06 23:54:32 +02:00
|
|
|
:placeholder='$t("common.email")' autocomplete='email' name='email')
|
2019-04-03 00:25:12 +02:00
|
|
|
span(slot='prepend') @
|
2019-04-23 13:45:52 +00:00
|
|
|
|
2019-06-07 17:02:33 +02:00
|
|
|
el-input.mb-2(v-model='user.password' type="password" placeholder="Password" name='password' required)
|
2019-04-03 00:25:12 +02:00
|
|
|
v-icon(name='lock' slot='prepend')
|
|
|
|
|
|
2019-04-26 23:14:43 +02:00
|
|
|
el-input.mb-2(v-model='user.description' type="textarea" rows='3' :placeholder="$t('common.description')")
|
2019-04-03 00:25:12 +02:00
|
|
|
v-icon(name='envelope-open-text')
|
|
|
|
|
|
2019-06-06 23:54:32 +02:00
|
|
|
el-button(plain type="success" native-type='submit'
|
2019-06-07 17:02:33 +02:00
|
|
|
:disabled='disabled') {{$t('common.send')}} <v-icon name='chevron-right'/>
|
2019-04-03 00:25:12 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-04-05 00:10:19 +02:00
|
|
|
import { mapActions } from 'vuex'
|
2019-04-03 00:25:12 +02:00
|
|
|
import { Message } from 'element-ui'
|
2019-06-07 17:02:33 +02:00
|
|
|
import get from 'lodash/get'
|
2019-04-03 00:25:12 +02:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'Register',
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
error: {},
|
|
|
|
|
user: { }
|
|
|
|
|
}
|
2019-05-30 12:04:14 +02:00
|
|
|
},
|
|
|
|
|
computed: {
|
2019-06-06 23:54:32 +02:00
|
|
|
disabled () {
|
|
|
|
|
if (process.server) return false
|
|
|
|
|
return !this.user.password || !this.user.email || !this.user.description
|
|
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions(['login']),
|
|
|
|
|
async register () {
|
|
|
|
|
try {
|
2019-06-18 14:45:04 +02:00
|
|
|
const { user } = await this.$axios.$post('/user/register', this.user)
|
2019-04-26 23:14:43 +02:00
|
|
|
Message({
|
2019-06-07 17:02:33 +02:00
|
|
|
message: this.$t(`register.${user.is_admin ? 'admin_' : ''}complete`),
|
2019-04-26 23:14:43 +02:00
|
|
|
type: 'success'
|
|
|
|
|
})
|
2019-05-30 12:04:14 +02:00
|
|
|
this.$router.replace("/")
|
2019-04-03 00:25:12 +02:00
|
|
|
} catch (e) {
|
2019-06-07 17:02:33 +02:00
|
|
|
const error = get(e, 'e.response.data.errors[0].message', String(e))
|
2019-04-03 00:25:12 +02:00
|
|
|
Message({
|
2019-05-30 12:12:51 +02:00
|
|
|
message: this.$t('register.error') + this.$t(error),
|
2019-04-03 00:25:12 +02:00
|
|
|
type: 'error'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|