File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { BrowserRouter , Routes , Route } from "react-router" ;
1+ import { BrowserRouter , Navigate , Routes , Route } from "react-router" ;
22import { ThemeProvider } from "./contexts/ThemeContext" ;
33import { LanguageProvider } from "./contexts/LanguageContext" ;
44import { Layout } from "./components/Layout" ;
@@ -19,6 +19,11 @@ import { LoginPage } from "./pages/LoginPage";
1919import { SignupPage } from "./pages/SignupPage" ;
2020import { ProfilePage } from "./pages/ProfilePage" ;
2121import { SettingsPage } from "./pages/SettingsPage" ;
22+ import { isAuthenticated } from "./auth" ;
23+
24+ function HomeRoute ( ) {
25+ return isAuthenticated ( ) ? < Navigate to = "/workspace" replace /> : < HomePage /> ;
26+ }
2227
2328export default function App ( ) {
2429 return (
@@ -28,7 +33,7 @@ export default function App() {
2833 < LanguageDomSync />
2934 < Routes >
3035 < Route element = { < PublicLayout /> } >
31- < Route path = "/" element = { < HomePage /> } />
36+ < Route path = "/" element = { < HomeRoute /> } />
3237 </ Route >
3338 < Route element = { < AuthLayout /> } >
3439 < Route path = "/login" element = { < LoginPage /> } />
Original file line number Diff line number Diff line change 1+ const AUTH_SESSION_KEY = "codedock-authenticated" ;
2+
3+ export function isAuthenticated ( ) {
4+ if ( typeof window === "undefined" || typeof window . localStorage === "undefined" ) {
5+ return false ;
6+ }
7+
8+ return window . localStorage . getItem ( AUTH_SESSION_KEY ) === "true" ;
9+ }
10+
11+ export function setAuthenticated ( ) {
12+ if ( typeof window === "undefined" || typeof window . localStorage === "undefined" ) {
13+ return ;
14+ }
15+
16+ window . localStorage . setItem ( AUTH_SESSION_KEY , "true" ) ;
17+ }
18+
19+ export function clearAuthenticated ( ) {
20+ if ( typeof window === "undefined" || typeof window . localStorage === "undefined" ) {
21+ return ;
22+ }
23+
24+ window . localStorage . removeItem ( AUTH_SESSION_KEY ) ;
25+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 DropdownMenuTrigger ,
1717} from "./ui/dropdown-menu" ;
1818import { useTheme } from "../contexts/ThemeContext" ;
19+ import { clearAuthenticated } from "../auth" ;
1920
2021const navItems = [
2122 { path : "/workspace" , label : "Dashboard" } ,
@@ -38,6 +39,7 @@ export function Layout() {
3839
3940 const isActive = ( path : string ) => location . pathname === path ;
4041 const handleLogout = ( ) => {
42+ clearAuthenticated ( ) ;
4143 navigate ( "/login" ) ;
4244 } ;
4345
@@ -90,7 +92,7 @@ export function Layout() {
9092 >
9193 < div className = "relative mx-auto flex w-[min(1400px,100%)] items-center justify-between gap-4" >
9294 < Link
93- to = "/"
95+ to = "/workspace "
9496 className = "codedock-brand-link flex items-center gap-3 no-underline transition-all duration-300"
9597 style = { {
9698 color : "var(--white)" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { CodeDockWordmark } from "../components/CodeDockWordmark";
1818import { CoffeeLogo } from "../components/CoffeeLogo" ;
1919import { useLanguage } from "../contexts/LanguageContext" ;
2020import { useTheme } from "../contexts/ThemeContext" ;
21+ import { setAuthenticated } from "../auth" ;
2122
2223const loginDemoMessagesKo = [
2324 { speaker : "CodeDock" , text : "위험 파일 3개를 먼저 묶었어요." , tone : "#B7FFE3" } ,
@@ -189,12 +190,12 @@ export function LoginPage() {
189190
190191 const handleSubmit = ( event : FormEvent < HTMLFormElement > ) => {
191192 event . preventDefault ( ) ;
192- console . log ( "Login:" , { email , password , rememberMe } ) ;
193+ setAuthenticated ( ) ;
193194 navigate ( "/workspace" ) ;
194195 } ;
195196
196197 const handleGithubLogin = ( ) => {
197- console . log ( "GitHub Login" ) ;
198+ setAuthenticated ( ) ;
198199 navigate ( "/workspace" ) ;
199200 } ;
200201
You can’t perform that action at this time.
0 commit comments