fix(account): redirect to auth page if unauth user is in user page (#3008)
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
@@ -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}</>;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user