Remove demo mode

Removes demo mode to ensure proper Supabase functionality.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 10:20:14 +00:00
parent 7b2ce776e4
commit 8e1f2de87e
3 changed files with 27 additions and 110 deletions

View File

@@ -14,22 +14,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
const [loading, setLoading] = useState(true);
useEffect(() => {
// 데모 모드 사용자 체크
const checkDemoUser = () => {
const demoUser = localStorage.getItem('demo_user');
if (demoUser) {
try {
const parsedUser = JSON.parse(demoUser) as User;
setUser(parsedUser);
// 데모 모드에서는 session이 null이지만 user는 있을 수 있음
setSession(null);
} catch (error) {
console.error('데모 사용자 파싱 오류:', error);
localStorage.removeItem('demo_user');
}
}
};
// 현재 세션 체크
const getSession = async () => {
try {
@@ -37,19 +21,12 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
if (error) {
console.error('세션 로딩 중 오류:', error);
// 실제 세션 로드 실패 시 데모 모드 사용자 확인
checkDemoUser();
} else if (data.session) {
setSession(data.session);
setUser(data.session.user);
} else {
// 세션이 없을 때 데모 모드 사용자 확인
checkDemoUser();
}
} catch (error) {
console.error('세션 확인 중 예외 발생:', error);
// 예외 발생 시 데모 모드 사용자 확인
checkDemoUser();
} finally {
setLoading(false);
}
@@ -63,18 +40,11 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
console.log('Supabase auth 이벤트:', event);
if (session) {
// 실제 세션이 있으면 데모 모드 사용자 제거
localStorage.removeItem('demo_user');
setSession(session);
setUser(session.user);
} else if (event === 'SIGNED_OUT') {
// 로그아웃 시 데모 모드 사용자도 제거
localStorage.removeItem('demo_user');
setSession(null);
setUser(null);
} else {
// 세션이 없을 때 데모 모드 사용자 확인
checkDemoUser();
}
setLoading(false);
@@ -87,25 +57,6 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
};
}, []);
// signOut 메소드 재정의 - 데모 모드 지원
const handleSignOut = async () => {
// 데모 모드 사용자 체크
const demoUser = localStorage.getItem('demo_user');
if (demoUser) {
localStorage.removeItem('demo_user');
setUser(null);
setSession(null);
toast({
title: '로그아웃 성공',
description: '다음에 또 만나요!',
});
return;
}
// 실제 Supabase 로그아웃
await authActions.signOut();
};
// 인증 작업 메서드들
const value: AuthContextType = {
session,
@@ -113,7 +64,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
loading,
signIn: authActions.signIn,
signUp: authActions.signUp,
signOut: handleSignOut,
signOut: authActions.signOut,
resetPassword: authActions.resetPassword,
};