aboutsummaryrefslogtreecommitdiff
path: root/src/components/registration/registration.js
blob: 93be9baab7c77c8cb4e113a7c319c2cbc9f7cb84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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