2017-04-16 02:12:23 +10:00
|
|
|
const registration = {
|
|
|
|
data: () => ({
|
|
|
|
user: {},
|
|
|
|
error: false,
|
|
|
|
registering: false
|
|
|
|
}),
|
2017-06-19 23:35:35 +10:00
|
|
|
computed: {
|
|
|
|
termsofservice () { return this.$store.state.config.tos }
|
|
|
|
},
|
2017-04-16 02:12:23 +10:00
|
|
|
methods: {
|
|
|
|
submit () {
|
|
|
|
this.registering = true
|
|
|
|
this.user.nickname = this.user.username
|
|
|
|
this.$store.state.api.backendInteractor.register(this.user).then(
|
|
|
|
(response) => {
|
|
|
|
if (response.ok) {
|
|
|
|
this.$store.dispatch('loginUser', this.user)
|
|
|
|
this.$router.push('/main/all')
|
|
|
|
this.registering = false
|
|
|
|
} else {
|
|
|
|
this.registering = false
|
|
|
|
response.json().then((data) => {
|
|
|
|
this.error = data.error
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default registration
|