fix: Redirect loop on auth failure
This commit is contained in:
@@ -9,18 +9,14 @@ import { MobileNav } from '@/app/(main)/MobileNav';
|
|||||||
export function App({ children }) {
|
export function App({ children }) {
|
||||||
const { user, isLoading, error } = useLoginQuery();
|
const { user, isLoading, error } = useLoginQuery();
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
const { pathname, router } = useNavigation();
|
const { pathname } = useNavigation();
|
||||||
|
|
||||||
if (isLoading || !config) {
|
if (isLoading || !config) {
|
||||||
return <Loading placement="absolute" />;
|
return <Loading placement="absolute" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (process.env.cloudMode) {
|
window.location.href = '/login';
|
||||||
window.location.href = '/login';
|
|
||||||
} else {
|
|
||||||
router.push('/login');
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function LogoutPage() {
|
|||||||
async function logout() {
|
async function logout() {
|
||||||
await post('/auth/logout');
|
await post('/auth/logout');
|
||||||
|
|
||||||
router.push('/login');
|
window.location.href = '/login';
|
||||||
}
|
}
|
||||||
|
|
||||||
removeClientAuthToken();
|
removeClientAuthToken();
|
||||||
|
|||||||
Reference in New Issue
Block a user