fix(account): redirect to auth page if unauth user is in user page (#3008)

This commit is contained in:
Huang Xin
2026-01-20 21:55:53 +01:00
committed by GitHub
parent 06d620db83
commit ea24b5a97a
3 changed files with 29 additions and 1 deletions
+6 -1
View File
@@ -231,7 +231,12 @@ export default function AuthPage() {
settings.keepLogin = false;
setSettings(settings);
saveSettings(envConfig, settings);
router.back();
const redirectTo = new URLSearchParams(window.location.search).get('redirect');
if (redirectTo) {
router.push(redirectTo);
} else {
router.back();
}
};
const getAuthLocalization = () => {
+10
View File
@@ -0,0 +1,10 @@
import { Metadata } from 'next';
export const metadata: Metadata = {
title: 'User Account',
description: 'Manage your account settings and subscription',
};
export default function ProfileLayout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
+13
View File
@@ -67,6 +67,19 @@ const ProfilePage = () => {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
useEffect(() => {
if (!mounted) return;
const isAuthenticated = user && token && appService;
if (isAuthenticated) return;
const timer = setTimeout(() => {
router.push('/auth?redirect=/library');
}, 1000);
return () => clearTimeout(timer);
}, [mounted, user, token, appService, router]);
useTheme({ systemUIVisible: false });
const { quotas, userProfilePlan = 'free' } = useQuotaStats();