aboutsummaryrefslogtreecommitdiff
path: root/src/boot/after_store.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-05-22 19:13:41 +0300
committerHenry Jameson <me@hjkos.com>2019-05-22 19:13:41 +0300
commite7a2a7267dbd8a4ee3d266d22249459d028569d6 (patch)
tree36bf31c489e26ae9adebdca8ee75f49c16688eb0 /src/boot/after_store.js
parent233506f6c1b0b16ca62c557ae6eca4a585e28a2c (diff)
Proper clientId/secret/token caching, MastoAPI registration
Diffstat (limited to 'src/boot/after_store.js')
-rw-r--r--src/boot/after_store.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 603de348..caaede59 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -3,6 +3,8 @@ import VueRouter from 'vue-router'
import routes from './routes'
import App from '../App.vue'
import { windowWidth } from '../services/window_utils/window_utils'
+import { getOrCreateApp, getClientToken } from '../services/new_api/oauth.js'
+import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
const getStatusnetConfig = async ({ store }) => {
try {
@@ -188,6 +190,17 @@ const getCustomEmoji = async ({ store }) => {
}
}
+const getAppSecret = async ({ store }) => {
+ const { state, commit } = store
+ const { oauth, instance } = state
+ return getOrCreateApp({ ...oauth, instance: instance.server, commit })
+ .then((app) => getClientToken({ ...app, instance: instance.server }))
+ .then((token) => {
+ commit('setClientToken', token.access_token)
+ commit('setBackendInteractor', backendInteractorService(store.getters.getToken()))
+ })
+}
+
const getNodeInfo = async ({ store }) => {
try {
const res = await window.fetch('/nodeinfo/2.0.json')
@@ -228,7 +241,7 @@ const setConfig = async ({ store }) => {
const apiConfig = configInfos[0]
const staticConfig = configInfos[1]
- await setSettings({ store, apiConfig, staticConfig })
+ await setSettings({ store, apiConfig, staticConfig }).then(getAppSecret({ store }))
}
const checkOAuthToken = async ({ store }) => {