refactor: move post-login push logic to single place

pull/563/head
Daniel Roe 2022-12-26 08:33:14 +01:00
rodzic d9e8703882
commit 72855d7725
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 22D5008E4F5D9B55
2 zmienionych plików z 9 dodań i 10 usunięć

Wyświetl plik

@ -88,7 +88,12 @@ async function loginTo(user?: Omit<UserLogin, 'account'> & { account?: AccountCr
}
}
if ('server' in route.params && user?.token && !useNuxtApp()._processingMiddleware) {
// This only cleans up the URL; page content should stay the same
if (route.path === '/signin/callback') {
await router.push('/home')
}
else if ('server' in route.params && user?.token && !useNuxtApp()._processingMiddleware) {
await router.push({
...route,
force: true,

Wyświetl plik

@ -2,8 +2,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const masto = createMasto()
if (process.client) {
const { query, path } = useRoute()
const router = useRouter()
const { query } = useRoute()
const user = typeof query.server === 'string' && typeof query.token === 'string'
? {
server: query.server,
@ -14,13 +13,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
nuxtApp.hook('app:suspense:resolve', () => {
// TODO: improve upstream to make this synchronous (delayed auth)
if (!masto.loggedIn.value) {
masto.loginTo(user).then(() => {
// This only cleans up the URL; page content should stay the same
if (path === '/signin/callback')
router.push('/home')
})
}
if (!masto.loggedIn.value)
masto.loginTo(user)
})
}