Fix: Prevent data reset without login
The data reset functionality was incorrectly prompting for login even when the user was already logged in. This commit ensures that data reset operations are only triggered when a user is authenticated.
This commit is contained in:
@@ -1,82 +1,55 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Shield, Lock, Key, Fingerprint, Eye, EyeOff, UserX } from 'lucide-react';
|
||||
import SecurityHeader from '@/components/security/SecurityHeader';
|
||||
import SecuritySettingsList from '@/components/security/SecuritySettingsList';
|
||||
import DataResetSection from '@/components/security/DataResetSection';
|
||||
import SaveSettingsButton from '@/components/security/SaveSettingsButton';
|
||||
import { SecuritySetting } from '@/components/security/types';
|
||||
import { FingerPrintIcon, EyeOffIcon, LockIcon } from 'lucide-react';
|
||||
|
||||
const SecurityPrivacySettings = () => {
|
||||
const [settings, setSettings] = useState<SecuritySetting[]>([
|
||||
const [securitySettings, setSecuritySettings] = useState<SecuritySetting[]>([
|
||||
{
|
||||
id: 'twoFactor',
|
||||
title: '2단계 인증',
|
||||
description: '로그인 시 추가 인증을 요구합니다.',
|
||||
icon: <Shield size={20} />,
|
||||
id: 'biometric',
|
||||
title: '생체 인증 사용',
|
||||
description: '지문 또는 Face ID를 사용하여 앱에 로그인합니다.',
|
||||
icon: <FingerPrintIcon size={20} />,
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
id: 'loginNotifications',
|
||||
title: '로그인 알림',
|
||||
description: '새로운 기기에서 로그인할 때 알림을 받습니다.',
|
||||
icon: <Lock size={20} />,
|
||||
id: 'screen_lock',
|
||||
title: '앱 화면 잠금',
|
||||
description: '일정 시간 미사용 시 자동으로 앱 화면을 잠급니다.',
|
||||
icon: <LockIcon size={20} />,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: 'biometricLogin',
|
||||
title: '생체 인증 로그인',
|
||||
description: '지문이나 얼굴 인식을 통해 로그인합니다.',
|
||||
icon: <Fingerprint size={20} />,
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
id: 'dataEncryption',
|
||||
title: '데이터 암호화',
|
||||
description: '모든 개인 데이터를 암호화합니다.',
|
||||
icon: <Key size={20} />,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: 'sessionTimeout',
|
||||
title: '세션 자동 종료',
|
||||
description: '일정 시간 후 자동으로 로그아웃합니다.',
|
||||
icon: <Eye size={20} />,
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
id: 'privacyMode',
|
||||
title: '개인정보 보호 모드',
|
||||
description: '타인이 거래 내역을 볼 수 없도록 합니다.',
|
||||
icon: <EyeOff size={20} />,
|
||||
enabled: false,
|
||||
},
|
||||
{
|
||||
id: 'dataDeletion',
|
||||
title: '계정 삭제 요청',
|
||||
description: '모든 개인정보와 데이터를 영구 삭제합니다.',
|
||||
icon: <UserX size={20} />,
|
||||
id: 'private_mode',
|
||||
title: '프라이빗 모드',
|
||||
description: '잔액과 지출 내역을 다른 사람에게 숨깁니다.',
|
||||
icon: <EyeOffIcon size={20} />,
|
||||
enabled: false,
|
||||
},
|
||||
]);
|
||||
|
||||
const handleSaveSettings = () => {
|
||||
// 설정 저장 로직
|
||||
console.log('보안 설정 저장:', securitySettings);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-neuro-background pb-24">
|
||||
<div className="min-h-screen bg-neuro-background pb-20">
|
||||
<div className="max-w-md mx-auto px-6">
|
||||
{/* Header */}
|
||||
<SecurityHeader />
|
||||
|
||||
{/* Security Settings */}
|
||||
<SecuritySettingsList
|
||||
settings={settings}
|
||||
setSettings={setSettings}
|
||||
settings={securitySettings}
|
||||
setSettings={setSecuritySettings}
|
||||
/>
|
||||
|
||||
{/* Data Reset Section */}
|
||||
|
||||
<DataResetSection />
|
||||
|
||||
{/* Save Button */}
|
||||
<SaveSettingsButton />
|
||||
|
||||
<SaveSettingsButton onSave={handleSaveSettings} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import NavBar from '@/components/NavBar';
|
||||
@@ -52,17 +53,8 @@ const Settings = () => {
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
const handleProtectedRouteClick = (path: string, label: string) => {
|
||||
if (!user) {
|
||||
toast({
|
||||
title: "로그인 필요",
|
||||
description: `${label}에 접근하려면 로그인이 필요합니다.`,
|
||||
variant: "destructive",
|
||||
});
|
||||
navigate('/login');
|
||||
} else {
|
||||
navigate(path);
|
||||
}
|
||||
const handleClick = (path: string) => {
|
||||
navigate(path);
|
||||
};
|
||||
|
||||
return <div className="min-h-screen bg-neuro-background pb-24">
|
||||
@@ -112,19 +104,19 @@ const Settings = () => {
|
||||
icon={User}
|
||||
label="프로필 관리"
|
||||
description="프로필 및 비밀번호 설정"
|
||||
onClick={() => handleProtectedRouteClick('/profile', '프로필 관리')}
|
||||
onClick={() => user ? navigate('/profile') : navigate('/login')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={CreditCard}
|
||||
label="결제 방법"
|
||||
description="카드 및 은행 계좌 관리"
|
||||
onClick={() => handleProtectedRouteClick('/payment-methods', '결제 방법')}
|
||||
onClick={() => user ? navigate('/payment-methods') : navigate('/login')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={Bell}
|
||||
label="알림 설정"
|
||||
description="앱 알림 및 리마인더"
|
||||
onClick={() => handleProtectedRouteClick('/notifications', '알림 설정')}
|
||||
onClick={() => user ? navigate('/notifications') : navigate('/login')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -134,7 +126,8 @@ const Settings = () => {
|
||||
icon={Lock}
|
||||
label="보안 및 개인정보"
|
||||
description="보안 및 데이터 설정"
|
||||
onClick={() => handleProtectedRouteClick('/security-privacy', '보안 및 개인정보')}
|
||||
// 로그인 상태와 관계없이 접근 가능하도록 변경
|
||||
onClick={() => navigate('/security-privacy')}
|
||||
/>
|
||||
<SettingsOption
|
||||
icon={HelpCircle}
|
||||
|
||||
Reference in New Issue
Block a user