No longer sending extra data, renamed some properties

This commit is contained in:
Henry Jameson 2019-06-13 00:39:51 +03:00
parent 77511a5338
commit af75c6d1ea
4 changed files with 14 additions and 10 deletions

View File

@ -246,9 +246,9 @@ const setConfig = async ({ store }) => {
const checkOAuthToken = async ({ store }) => { const checkOAuthToken = async ({ store }) => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
if (store.state.oauth.token) { if (store.state.oauth.userToken) {
try { try {
await store.dispatch('loginUser', store.state.oauth.token) await store.dispatch('loginUser', store.state.oauth.userToken)
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }

View File

@ -11,8 +11,9 @@ const LoginForm = {
}, },
methods: { methods: {
oAuthLogin () { oAuthLogin () {
const { clientId } = this.$store.state.oauth
const data = { const data = {
...this.$store.state.oauth, clientId,
instance: this.$store.state.instance.server, instance: this.$store.state.instance.server,
commit: this.$store.commit commit: this.$store.commit
} }
@ -21,8 +22,9 @@ const LoginForm = {
.then((app) => { oauthApi.login({ ...app, ...data }) }) .then((app) => { oauthApi.login({ ...app, ...data }) })
}, },
submit () { submit () {
const { clientId } = this.$store.state.oauth
const data = { const data = {
...this.$store.state.oauth, clientId,
instance: this.$store.state.instance.server, instance: this.$store.state.instance.server,
commit: this.$store.commit commit: this.$store.commit
} }

View File

@ -4,8 +4,10 @@ const oac = {
props: ['code'], props: ['code'],
mounted () { mounted () {
if (this.code) { if (this.code) {
const { clientId } = this.$store.state.oauth
oauth.getToken({ oauth.getToken({
...this.$store.state.oauth, clientId,
instance: this.$store.state.instance.server, instance: this.$store.state.instance.server,
code: this.code code: this.code
}).then((result) => { }).then((result) => {

View File

@ -2,8 +2,8 @@ const oauth = {
state: { state: {
clientId: false, clientId: false,
clientSecret: false, clientSecret: false,
token: false, appToken: false,
clientToken: false userToken: false
}, },
mutations: { mutations: {
setClientData (state, { clientId, clientSecret }) { setClientData (state, { clientId, clientSecret }) {
@ -11,15 +11,15 @@ const oauth = {
state.clientSecret = clientSecret state.clientSecret = clientSecret
}, },
setClientToken (state, token) { setClientToken (state, token) {
state.clientToken = token state.appToken = token
}, },
setToken (state, token) { setToken (state, token) {
state.token = token state.userToken = token
} }
}, },
getters: { getters: {
getToken: state => () => { getToken: state => () => {
return state.token || state.clientToken return state.userToken || state.appToken
} }
} }
} }