From af75c6d1ea392477c647708dcd0e712c514a1b60 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 13 Jun 2019 00:39:51 +0300 Subject: [PATCH] No longer sending extra data, renamed some properties --- src/boot/after_store.js | 4 ++-- src/components/login_form/login_form.js | 6 ++++-- src/components/oauth_callback/oauth_callback.js | 4 +++- src/modules/oauth.js | 10 +++++----- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index caaede5968..4bcd1fb532 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -246,9 +246,9 @@ const setConfig = async ({ store }) => { const checkOAuthToken = async ({ store }) => { return new Promise(async (resolve, reject) => { - if (store.state.oauth.token) { + if (store.state.oauth.userToken) { try { - await store.dispatch('loginUser', store.state.oauth.token) + await store.dispatch('loginUser', store.state.oauth.userToken) } catch (e) { console.log(e) } diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 0097e18aa9..7d49fade79 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -11,8 +11,9 @@ const LoginForm = { }, methods: { oAuthLogin () { + const { clientId } = this.$store.state.oauth const data = { - ...this.$store.state.oauth, + clientId, instance: this.$store.state.instance.server, commit: this.$store.commit } @@ -21,8 +22,9 @@ const LoginForm = { .then((app) => { oauthApi.login({ ...app, ...data }) }) }, submit () { + const { clientId } = this.$store.state.oauth const data = { - ...this.$store.state.oauth, + clientId, instance: this.$store.state.instance.server, commit: this.$store.commit } diff --git a/src/components/oauth_callback/oauth_callback.js b/src/components/oauth_callback/oauth_callback.js index 48ddd10d97..2c6ca235a1 100644 --- a/src/components/oauth_callback/oauth_callback.js +++ b/src/components/oauth_callback/oauth_callback.js @@ -4,8 +4,10 @@ const oac = { props: ['code'], mounted () { if (this.code) { + const { clientId } = this.$store.state.oauth + oauth.getToken({ - ...this.$store.state.oauth, + clientId, instance: this.$store.state.instance.server, code: this.code }).then((result) => { diff --git a/src/modules/oauth.js b/src/modules/oauth.js index 242e29c33b..4b233b211a 100644 --- a/src/modules/oauth.js +++ b/src/modules/oauth.js @@ -2,8 +2,8 @@ const oauth = { state: { clientId: false, clientSecret: false, - token: false, - clientToken: false + appToken: false, + userToken: false }, mutations: { setClientData (state, { clientId, clientSecret }) { @@ -11,15 +11,15 @@ const oauth = { state.clientSecret = clientSecret }, setClientToken (state, token) { - state.clientToken = token + state.appToken = token }, setToken (state, token) { - state.token = token + state.userToken = token } }, getters: { getToken: state => () => { - return state.token || state.clientToken + return state.userToken || state.appToken } } }