aboutsummaryrefslogtreecommitdiff
path: root/src/components/oauth_callback/oauth_callback.js
blob: 2c6ca235a12e941e1f983fecd82c9805a7ea6e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import oauth from '../../services/new_api/oauth.js'

const oac = {
  props: ['code'],
  mounted () {
    if (this.code) {
      const { clientId } = this.$store.state.oauth

      oauth.getToken({
        clientId,
        instance: this.$store.state.instance.server,
        code: this.code
      }).then((result) => {
        this.$store.commit('setToken', result.access_token)
        this.$store.dispatch('loginUser', result.access_token)
        this.$router.push({ name: 'friends' })
      })
    }
  }
}

export default oac