mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2024-11-23 05:59:55 +00:00
fix(router): endless recursion in HMR, server selection not available (#2478)
Some checks are pending
Push & Release 🌍 / Automation 🎛️ (push) Waiting to run
Push & Release 🌍 / ${{ github.event_name == 'push' && 'Unstable 🚀⚠️' || 'Stable 🏷️✅' }} (push) Waiting to run
Push & Release 🌍 / GitHub CodeQL 🔬 (push) Waiting to run
Push & Release 🌍 / Deploy 🚀 (push) Blocked by required conditions
Some checks are pending
Push & Release 🌍 / Automation 🎛️ (push) Waiting to run
Push & Release 🌍 / ${{ github.event_name == 'push' && 'Unstable 🚀⚠️' || 'Stable 🏷️✅' }} (push) Waiting to run
Push & Release 🌍 / GitHub CodeQL 🔬 (push) Waiting to run
Push & Release 🌍 / Deploy 🚀 (push) Blocked by required conditions
This commit is contained in:
parent
91324c5164
commit
f15bcdeb07
@ -1,4 +1,4 @@
|
||||
import { watchSyncEffect } from 'vue';
|
||||
import { watch } from 'vue';
|
||||
import {
|
||||
createRouter,
|
||||
createWebHashHistory,
|
||||
@ -54,19 +54,21 @@ router.back = () => {
|
||||
leave: route.value.meta.layout.transition.leave ?? backTransition
|
||||
};
|
||||
|
||||
const historyState = router.options.history.state;
|
||||
|
||||
if (historyState && isStr(historyState.back)) {
|
||||
if (isStr(router.options.history.state.back)) {
|
||||
router.go(-1);
|
||||
} else {
|
||||
router.replace('/');
|
||||
void router.replace('/');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Re-run the middleware pipeline when the user logs out or state is cleared
|
||||
*/
|
||||
watchSyncEffect(() => {
|
||||
watch([
|
||||
() => remote.auth.currentUser,
|
||||
() => remote.auth.servers,
|
||||
() => remote.auth.currentServer
|
||||
], () => {
|
||||
if (!remote.auth.currentUser && remote.auth.servers.length <= 0) {
|
||||
/**
|
||||
* We run the redirect to /server/add as it's the first page in the login flow
|
||||
@ -91,5 +93,4 @@ watchSyncEffect(() => {
|
||||
) {
|
||||
void router.replace('/server/select');
|
||||
}
|
||||
}
|
||||
);
|
||||
}, { flush: 'sync' });
|
||||
|
@ -36,25 +36,21 @@ export async function loginGuard(
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
!jsonConfig.allowServerSelection
|
||||
&& serverRoutes.has(to.path)
|
||||
)
|
||||
|| (
|
||||
!isNil(remote.auth.currentServer)
|
||||
&& !isNil(remote.auth.currentUser)
|
||||
&& !isNil(remote.auth.currentUserToken)
|
||||
&& routes.has(to.path)
|
||||
)
|
||||
!isNil(remote.auth.currentServer)
|
||||
&& !isNil(remote.auth.currentUser)
|
||||
&& !isNil(remote.auth.currentUserToken)
|
||||
&& routes.has(to.path)
|
||||
) {
|
||||
return doRedir({ path: '/', replace: true }, to);
|
||||
}
|
||||
|
||||
if (!remote.auth.servers.length) {
|
||||
return doRedir({ path: serverAddUrl, replace: true }, to);
|
||||
} else if (isNil(remote.auth.currentServer)) {
|
||||
return doRedir({ path: serverSelectUrl, replace: true }, to);
|
||||
} else if (isNil(remote.auth.currentUser)) {
|
||||
if (jsonConfig.allowServerSelection) {
|
||||
if (!remote.auth.servers.length) {
|
||||
return doRedir({ path: serverAddUrl, replace: true }, to);
|
||||
} else if (isNil(remote.auth.currentServer)) {
|
||||
return doRedir({ path: serverSelectUrl, replace: true }, to);
|
||||
}
|
||||
} else {
|
||||
return doRedir({ path: serverLoginUrl, replace: true }, to);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user