🔥 remove: demo mode from todo, contacts, clock, questions, chat apps

- Enforce login redirect for unauthenticated users
- Remove demo banner, AuthGateModal, and GuestWelcomeModal
- Remove guest mode state variables and CSS styles
- Simplify showLogout to always show when user is logged in

Affected apps: todo-web, contacts-web, clock-web, questions-web, chat-web
This commit is contained in:
Till-JS 2026-01-30 17:21:22 +01:00
parent 68219a01df
commit f07387d12c
5 changed files with 76 additions and 603 deletions

View file

@ -24,11 +24,6 @@
import { getPillAppItems } from '@manacore/shared-branding';
import { getLanguageDropdownItems, getCurrentLanguageLabel } from '@manacore/shared-i18n';
import { setLocale, supportedLocales } from '$lib/i18n';
import {
AuthGateModal,
GuestWelcomeModal,
shouldShowGuestWelcome,
} from '@manacore/shared-auth-ui';
import type { LayoutData } from './$types';
// App switcher items
@ -40,17 +35,6 @@
let isSidebarMode = $state(false);
let isCollapsed = $state(false);
// Guest mode state
let showAuthGateModal = $state(false);
let authGateAction = $state<'save' | 'sync' | 'ai' | 'feature'>('ai');
// Guest welcome modal state
let showGuestWelcome = $state(false);
// Check if in guest mode
let isGuestMode = $derived(!authStore.isAuthenticated);
let sessionConversationCount = $derived(sessionConversationsStore.count);
// Use theme store's isDark directly
let isDark = $derived(theme.isDark);
@ -170,8 +154,15 @@
goto('/login');
}
// Initialize on mount - supports both authenticated and guest mode
// Initialize on mount - enforce login
onMount(async () => {
// Initialize auth and redirect if not authenticated
await authStore.initialize();
if (!authStore.isAuthenticated) {
goto('/login');
return;
}
// Initialize theme
theme.initialize();
@ -189,27 +180,18 @@
collapsedStore.set(true);
}
await authStore.initialize();
// Load user settings
await userSettings.load();
// Show guest welcome modal for unauthenticated users
if (!authStore.isAuthenticated && shouldShowGuestWelcome('chat')) {
showGuestWelcome = true;
// Check for session conversations to migrate
if (conversationsStore.hasSessionConversations) {
await conversationsStore.migrateSessionConversations();
}
// Load user settings if authenticated
if (authStore.isAuthenticated) {
await userSettings.load();
// Check for session conversations to migrate
if (conversationsStore.hasSessionConversations) {
await conversationsStore.migrateSessionConversations();
}
// Redirect to start page if on /chat and a custom start page is set
const currentPath = window.location.pathname;
if (currentPath === '/chat' && userSettings.startPage && userSettings.startPage !== '/chat') {
goto(userSettings.startPage, { replaceState: true });
}
// Redirect to start page if on /chat and a custom start page is set
const currentPath = window.location.pathname;
if (currentPath === '/chat' && userSettings.startPage && userSettings.startPage !== '/chat') {
goto(userSettings.startPage, { replaceState: true });
}
isChecking = false;
@ -229,22 +211,8 @@
</div>
</div>
{:else}
<!-- Guest Mode Banner -->
{#if isGuestMode}
<div class="guest-banner">
<span>
Du bist im Gast-Modus.
{#if sessionConversationCount > 0}
{sessionConversationCount}
{sessionConversationCount === 1 ? 'Unterhaltung' : 'Unterhaltungen'} in dieser Session.
{/if}
</span>
<button onclick={() => goto('/login')}>Anmelden</button>
</div>
{/if}
<!-- Navigation Layout -->
<div class="layout-container" class:has-guest-banner={isGuestMode}>
<div class="layout-container">
<!-- Floating/Sidebar Pill Navigation -->
<PillNavigation
items={navItems}
@ -296,91 +264,15 @@
{/if}
</main>
</div>
<!-- Auth Gate Modal -->
<AuthGateModal
visible={showAuthGateModal}
onClose={() => (showAuthGateModal = false)}
onLogin={() => {
showAuthGateModal = false;
if (typeof sessionStorage !== 'undefined') {
sessionStorage.setItem('auth-return-url', window.location.pathname);
}
goto('/login');
}}
onRegister={() => {
showAuthGateModal = false;
if (typeof sessionStorage !== 'undefined') {
sessionStorage.setItem('auth-return-url', window.location.pathname);
}
goto('/register');
}}
action={authGateAction}
migrationCount={sessionConversationCount}
locale={currentLocale === 'en' ? 'en' : 'de'}
/>
<!-- Guest Welcome Modal -->
<GuestWelcomeModal
appId="chat"
visible={showGuestWelcome}
onClose={() => (showGuestWelcome = false)}
onLogin={() => {
showGuestWelcome = false;
goto('/login');
}}
onRegister={() => {
showGuestWelcome = false;
goto('/register');
}}
helpHref="/help"
locale={currentLocale === 'en' ? 'en' : 'de'}
/>
{/if}
<style>
.guest-banner {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 60;
background-color: #3b82f6;
color: white;
padding: 0.5rem 1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
font-size: 0.875rem;
}
.guest-banner button {
background-color: white;
color: #3b82f6;
padding: 0.25rem 0.75rem;
border-radius: 0.375rem;
font-weight: 500;
font-size: 0.875rem;
border: none;
cursor: pointer;
transition: background-color 0.15s;
}
.guest-banner button:hover {
background-color: #f0f9ff;
}
.layout-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.layout-container.has-guest-banner {
padding-top: 40px;
}
.main-content {
flex: 1;
transition: all 300ms ease;