aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjasper <jasper92341@hotmail.com>2019-04-01 12:32:13 -0700
committerjasper <jasper92341@hotmail.com>2019-04-01 12:32:13 -0700
commit90939f198b896c0644864f65a430e44e8d3a259c (patch)
tree57c6ad291f0f88d679e355665d5c15576a5ae501
parent8fc10dc17741fa9713604cc8846032104edf11cb (diff)
Fix login handling
-rw-r--r--src/boot/after_store.js42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 8db1c39d..fca750ae 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -228,6 +228,19 @@ const setConfig = async ({ store }) => {
await setSettings({ store, apiConfig, staticConfig })
}
+const checkOAuthToken = async ({ store }) => {
+ return new Promise(async (resolve, reject) => {
+ if (store.state.oauth.token) {
+ try {
+ await store.dispatch('loginUser', store.state.oauth.token)
+ } catch (e) {
+ console.log(e)
+ }
+ }
+ resolve()
+ })
+}
+
const afterStoreSetup = async ({ store, i18n }) => {
if (store.state.config.customTheme) {
// This is a hack to deal with async loading of config.json and themes
@@ -240,26 +253,15 @@ const afterStoreSetup = async ({ store, i18n }) => {
}
// Now we can try getting the server settings and logging in
- if (store.state.oauth.token) {
- await Promise.all([
- setConfig({ store }),
- getTOS({ store }),
- getInstancePanel({ store }),
- getStaticEmoji({ store }),
- getCustomEmoji({ store }),
- getNodeInfo({ store }),
- store.dispatch('loginUser', store.state.oauth.token)
- ])
- } else {
- await Promise.all([
- setConfig({ store }),
- getTOS({ store }),
- getInstancePanel({ store }),
- getStaticEmoji({ store }),
- getCustomEmoji({ store }),
- getNodeInfo({ store })
- ])
- }
+ await Promise.all([
+ checkOAuthToken({ store }),
+ setConfig({ store }),
+ getTOS({ store }),
+ getInstancePanel({ store }),
+ getStaticEmoji({ store }),
+ getCustomEmoji({ store }),
+ getNodeInfo({ store })
+ ])
const router = new VueRouter({
mode: 'history',