Implement user authentication

Implement login functionality and user authentication logic.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 06:50:56 +00:00
parent bfb446fe1a
commit 33f1a94a81
8 changed files with 387 additions and 112 deletions

View File

@@ -5,6 +5,7 @@ import NavBar from '@/components/NavBar';
import SyncSettings from '@/components/SyncSettings';
import { User, CreditCard, Bell, Lock, HelpCircle, LogOut, ChevronRight } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useAuth } from '@/contexts/AuthContext';
const SettingsOption = ({
icon: Icon,
@@ -35,6 +36,13 @@ const SettingsOption = ({
const Settings = () => {
const navigate = useNavigate();
const { user, signOut } = useAuth();
const handleLogout = async () => {
await signOut();
navigate('/login');
};
return <div className="min-h-screen bg-neuro-background pb-24">
<div className="max-w-md mx-auto px-6">
{/* Header */}
@@ -47,8 +55,12 @@ const Settings = () => {
<User size={24} />
</div>
<div>
<h2 className="font-semibold text-lg"></h2>
<p className="text-sm text-gray-500">honggildong@example.com</p>
<h2 className="font-semibold text-lg">
{user ? user.user_metadata?.username || '사용자' : '로그인 필요'}
</h2>
<p className="text-sm text-gray-500">
{user ? user.email : '계정에 로그인하세요'}
</p>
</div>
</div>
</header>
@@ -74,7 +86,12 @@ const Settings = () => {
</div>
<div className="mt-8">
<SettingsOption icon={LogOut} label="로그아웃" color="text-neuro-expense" />
<SettingsOption
icon={LogOut}
label={user ? "로그아웃" : "로그인"}
color="text-neuro-expense"
onClick={user ? handleLogout : () => navigate('/login')}
/>
</div>
<div className="mt-12 text-center text-xs text-gray-400">