Enhance authentication and debugging experience by adding detailed logging for cookie checks, session management, and user redirection. Update middleware to log authentication cookie status and user login state. Refactor login and debug pages to use hard redirects for improved reliability and include session data display. Implement custom cookie handling in Supabase client for better session management.
This commit is contained in:
11
lib/auth.tsx
11
lib/auth.tsx
@@ -94,10 +94,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
return { error };
|
||||
}
|
||||
|
||||
// 登录成功,设置会话和用户信息
|
||||
console.log('登录成功,用户信息:', data.user?.email);
|
||||
setSession(data.session);
|
||||
setUser(data.user);
|
||||
|
||||
router.push('/analytics');
|
||||
// 使用硬重定向代替router.push,确保页面完全刷新
|
||||
console.log('准备重定向到分析页面');
|
||||
|
||||
// 添加短暂延时确保状态已更新,然后重定向
|
||||
setTimeout(() => {
|
||||
window.location.href = '/analytics';
|
||||
}, 100);
|
||||
|
||||
return {};
|
||||
} catch (error) {
|
||||
console.error('登录过程出错:', error);
|
||||
|
||||
Reference in New Issue
Block a user