Add a registration form.
This commit is contained in:
parent
6d7fcb057d
commit
a766e886f5
7 changed files with 169 additions and 16 deletions
29
src/components/registration/registration.js
Normal file
29
src/components/registration/registration.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
const registration = {
|
||||
data: () => ({
|
||||
user: {},
|
||||
error: false,
|
||||
registering: false
|
||||
}),
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue