🐛 fix(auth): Implement user redirection to dashboard upon authentication

This commit is contained in:
web
2025-07-24 10:10:31 -07:00
committed by speakeloudest
parent 6e62353096
commit 61165c88c4
2 changed files with 32 additions and 2 deletions
+22 -1
View File
@@ -2,8 +2,29 @@ import { GlobalMap } from '@/components/main/global-map';
import { Hero } from '@/components/main/hero';
import { ProductShowcase } from '@/components/main/product-showcase/index';
import { Stats } from '@/components/main/stats';
import { queryUserInfo } from '@/services/user/user';
import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';
export default async function Home() {
const Authorization = (await cookies()).get('Authorization')?.value;
if (Authorization) {
let user = null;
try {
user = await queryUserInfo({
skipErrorHandler: true,
Authorization,
}).then((res) => res.data.data);
} catch (error) {
console.log('Token validation failed:', error);
}
if (user) {
redirect('/dashboard');
}
}
export default function Home() {
return (
<main className='container space-y-16'>
<Hero />