forked from 77media/video-flow
修复一些问题
This commit is contained in:
parent
90df36a8a0
commit
c6a7889b43
@ -2,7 +2,7 @@
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useRouter, usePathname } from 'next/navigation';
|
||||
import { checkAuth, isAuthenticated } from '@/lib/auth';
|
||||
import { checkAuth, getUserProfile, isAuthenticated } from '@/lib/auth';
|
||||
import GlobalLoad from '../common/GlobalLoad';
|
||||
|
||||
interface AuthGuardProps {
|
||||
@ -36,12 +36,10 @@ export default function AuthGuard({ children }: AuthGuardProps) {
|
||||
|
||||
try {
|
||||
// 调用鉴权接口验证token
|
||||
const isValid = await checkAuth();
|
||||
|
||||
if (isValid) {
|
||||
const user = await getUserProfile();
|
||||
if (user) {
|
||||
setIsAuthorized(true);
|
||||
} else {
|
||||
// Token无效,重定向到登录页
|
||||
router.push('/login');
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -268,8 +268,8 @@ export function TopBar({
|
||||
{/* User Info */}
|
||||
<div className="p-4">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="h-10 w-10 rounded-full bg-[#1E4D3E] flex items-center justify-center text-white font-semibold">
|
||||
{currentUser.name ? currentUser.name.charAt(0) : ""}
|
||||
<div className="h-10 w-10 rounded-full bg-[#C73BFF] flex items-center justify-center text-white font-semibold">
|
||||
MF
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<p className="text-sm font-medium">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user