aboutsummaryrefslogtreecommitdiff
path: root/src/modules/oauth.js
blob: 332b8db2d12cd29bb68f4dd7a411c0bd972e11a4 (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
30
31
32
33
34
const oauth = {
  state: {
    clientId: false,
    clientSecret: false,
    /* App token is authentication for app without any user, used mostly for
     * MastoAPI's registration of new users, stored so that we can fall back to
     * it on logout
     */
    appToken: false,
    /* User token is authentication for app with user, this is for every calls
     * that need authorized user to be successful (i.e. posting, liking etc)
     */
    userToken: false
  },
  mutations: {
    setClientData (state, { clientId, clientSecret }) {
      state.clientId = clientId
      state.clientSecret = clientSecret
    },
    setClientToken (state, token) {
      state.appToken = token
    },
    setToken (state, token) {
      state.userToken = token
    }
  },
  getters: {
    getToken: state => () => {
      return state.userToken || state.appToken
    }
  }
}

export default oauth