File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,7 +44,35 @@ document.addEventListener('DOMContentLoaded', () => {
4444 // Load lessons data
4545 loadLessons ( ) ;
4646
47- // Start the application
47+ // Check for existing session and auto-login
48+ const storedUsername = localStorage . getItem ( STORAGE_KEYS . CURRENT_USER ) ;
49+ if ( storedUsername ) {
50+ const users = getUsers ( ) ;
51+ if ( users [ storedUsername ] ) {
52+ // Auto-login the user
53+ users [ storedUsername ] = updateLoginStreak ( users [ storedUsername ] ) ;
54+ saveUsers ( users ) ;
55+
56+ app . loggedUser = users [ storedUsername ] ;
57+
58+ printLine ( 'Welcome to TerminaLingo!' , 'info' ) ;
59+ printLine ( '=====================================' ) ;
60+ printBlankLine ( ) ;
61+ printLine ( `Automatically logged in as: ${ storedUsername } ` , 'success' ) ;
62+ printLine ( `Login streak: ${ app . loggedUser . dailyLoginStreak } days` , 'info' ) ;
63+ printLine ( `Lessons completed: ${ app . loggedUser . lessonsTotal } ` , 'info' ) ;
64+ printLine ( `Words learned: ${ app . loggedUser . learnedWords . length } ` , 'info' ) ;
65+ printBlankLine ( ) ;
66+
67+ showLanguageMenu ( ) ;
68+ return ;
69+ } else {
70+ // User no longer exists, clear the stored session
71+ localStorage . removeItem ( STORAGE_KEYS . CURRENT_USER ) ;
72+ }
73+ }
74+
75+ // Start the application with auth menu
4876 showAuthMenu ( ) ;
4977} ) ;
5078
You can’t perform that action at this time.
0 commit comments