forked from AkkomaGang/akkoma-fe
Fix login handling
This commit is contained in:
parent
8fc10dc177
commit
90939f198b
1 changed files with 22 additions and 20 deletions
|
@ -228,6 +228,19 @@ const setConfig = async ({ store }) => {
|
||||||
await setSettings({ store, apiConfig, staticConfig })
|
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 }) => {
|
const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
if (store.state.config.customTheme) {
|
if (store.state.config.customTheme) {
|
||||||
// This is a hack to deal with async loading of config.json and themes
|
// This is a hack to deal with async loading of config.json and themes
|
||||||
|
@ -240,18 +253,8 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we can try getting the server settings and logging in
|
// 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([
|
await Promise.all([
|
||||||
|
checkOAuthToken({ store }),
|
||||||
setConfig({ store }),
|
setConfig({ store }),
|
||||||
getTOS({ store }),
|
getTOS({ store }),
|
||||||
getInstancePanel({ store }),
|
getInstancePanel({ store }),
|
||||||
|
@ -259,7 +262,6 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
getCustomEmoji({ store }),
|
getCustomEmoji({ store }),
|
||||||
getNodeInfo({ store })
|
getNodeInfo({ store })
|
||||||
])
|
])
|
||||||
}
|
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
|
|
Loading…
Reference in a new issue