RoyAalekh commited on
Commit
50e2e6d
·
1 Parent(s): f6359a6

Simplify conference flow: demo account stays logged in

Browse files

- Demo users always redirect to welcome screen from /
- Remove auto-login complexity from welcome.html
- Add /app route for authenticated access to main form
- Add Welcome button to form header for easy navigation
- Conference setup: Ishita logs in once, visitors use welcome screen
- Eliminates authentication friction during conference demonstrations

Files changed (6) hide show
  1. app.py +23 -1
  2. static/index.html +3 -2
  3. static/map.html +2 -2
  4. static/sw.js +1 -1
  5. static/welcome.html +4 -14
  6. version.json +1 -1
app.py CHANGED
@@ -495,6 +495,10 @@ async def read_root(request: Request):
495
  if not user:
496
  return RedirectResponse(url="/welcome")
497
 
 
 
 
 
498
  try:
499
  with open("static/index.html", encoding="utf-8") as f:
500
  content = f.read()
@@ -504,6 +508,24 @@ async def read_root(request: Request):
504
  raise HTTPException(status_code=404, detail="Frontend not found")
505
 
506
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  @app.get("/map", response_class=HTMLResponse, tags=["Frontend"])
508
  async def serve_map(request: Request):
509
  """Serve the map page with auth check"""
@@ -512,7 +534,7 @@ async def serve_map(request: Request):
512
 
513
  # Regular authentication check
514
  if not user:
515
- return RedirectResponse(url="/login")
516
 
517
  return RedirectResponse(url="/static/map.html")
518
 
 
495
  if not user:
496
  return RedirectResponse(url="/welcome")
497
 
498
+ # If user is demo account, always show welcome screen for conference
499
+ if user.get('role') == 'demo_user' or 'demo_view' in user.get('permissions', []):
500
+ return RedirectResponse(url="/welcome")
501
+
502
  try:
503
  with open("static/index.html", encoding="utf-8") as f:
504
  content = f.read()
 
508
  raise HTTPException(status_code=404, detail="Frontend not found")
509
 
510
 
511
+ @app.get("/app", response_class=HTMLResponse, tags=["Frontend"])
512
+ async def serve_app(request: Request):
513
+ """Serve the main application for authenticated users"""
514
+ # Check if user is authenticated
515
+ user = get_current_user(request)
516
+
517
+ # Regular authentication check
518
+ if not user:
519
+ return RedirectResponse(url="/welcome")
520
+
521
+ try:
522
+ with open("static/index.html", encoding="utf-8") as f:
523
+ content = f.read()
524
+ return HTMLResponse(content=content)
525
+ except FileNotFoundError:
526
+ logger.error("index.html not found")
527
+ raise HTTPException(status_code=404, detail="Frontend not found")
528
+
529
  @app.get("/map", response_class=HTMLResponse, tags=["Frontend"])
530
  async def serve_map(request: Request):
531
  """Serve the map page with auth check"""
 
534
 
535
  # Regular authentication check
536
  if not user:
537
+ return RedirectResponse(url="/welcome")
538
 
539
  return RedirectResponse(url="/static/map.html")
540
 
static/index.html CHANGED
@@ -953,7 +953,7 @@
953
  // Force refresh if we detect cached version
954
  (function() {
955
  const currentVersion = '5.1.1';
956
- const timestamp = '1761485558'; // Cache-busting bump
957
  const lastVersion = sessionStorage.getItem('treetrack_version');
958
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
959
 
@@ -990,6 +990,7 @@
990
  <div class="tt-user-role" id="userRole">User</div>
991
  </div>
992
  </div>
 
993
  <a href="/static/map.html" class="tt-btn tt-btn-secondary" id="viewMapBtn">View Map</a>
994
  <button id="logoutBtn" class="tt-btn tt-btn-secondary">Logout</button>
995
  </div>
@@ -1198,7 +1199,7 @@
1198
  </div>
1199
  </div>
1200
 
1201
- <script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1761485558"></script>
1202
 
1203
  <script>
1204
  // Idle-time prefetch of map assets to speed up first navigation
 
953
  // Force refresh if we detect cached version
954
  (function() {
955
  const currentVersion = '5.1.1';
956
+ const timestamp = '1761485777'; // Cache-busting bump
957
  const lastVersion = sessionStorage.getItem('treetrack_version');
958
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
959
 
 
990
  <div class="tt-user-role" id="userRole">User</div>
991
  </div>
992
  </div>
993
+ <a href="/welcome" class="tt-btn tt-btn-outline" id="welcomeBtn">Welcome</a>
994
  <a href="/static/map.html" class="tt-btn tt-btn-secondary" id="viewMapBtn">View Map</a>
995
  <button id="logoutBtn" class="tt-btn tt-btn-secondary">Logout</button>
996
  </div>
 
1199
  </div>
1200
  </div>
1201
 
1202
+ <script type="module" src="/static/js/tree-track-app.js?v=5.1.1&t=1761485777"></script>
1203
 
1204
  <script>
1205
  // Idle-time prefetch of map assets to speed up first navigation
static/map.html CHANGED
@@ -799,7 +799,7 @@
799
  // Force refresh if we detect cached version
800
  (function() {
801
  const currentVersion = '5.1.1';
802
- const timestamp = '1761485558'; // Current timestamp for cache busting
803
  const lastVersion = sessionStorage.getItem('treetrack_version');
804
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
805
 
@@ -925,7 +925,7 @@ const timestamp = '1761485558'; // Current timestamp for cache busting
925
 
926
  <!-- Leaflet JS -->
927
  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
928
- <script src="/static/map.js?v=5.1.1&t=1761485558">
929
 
930
  "default-state": {
931
  gradients: [
 
799
  // Force refresh if we detect cached version
800
  (function() {
801
  const currentVersion = '5.1.1';
802
+ const timestamp = '1761485777'; // Current timestamp for cache busting
803
  const lastVersion = sessionStorage.getItem('treetrack_version');
804
  const lastTimestamp = sessionStorage.getItem('treetrack_timestamp');
805
 
 
925
 
926
  <!-- Leaflet JS -->
927
  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
928
+ <script src="/static/map.js?v=5.1.1&t=1761485777">
929
 
930
  "default-state": {
931
  gradients: [
static/sw.js CHANGED
@@ -1,5 +1,5 @@
1
  // TreeTrack Service Worker - PWA and Offline Support
2
- const VERSION = 1761485558; // Cache busting bump - force clients to fetch new static assets and header image change
3
  const CACHE_NAME = `treetrack-v${VERSION}`;
4
  const STATIC_CACHE = `static-v${VERSION}`;
5
  const API_CACHE = `api-v${VERSION}`;
 
1
  // TreeTrack Service Worker - PWA and Offline Support
2
+ const VERSION = 1761485777; // Cache busting bump - force clients to fetch new static assets and header image change
3
  const CACHE_NAME = `treetrack-v${VERSION}`;
4
  const STATIC_CACHE = `static-v${VERSION}`;
5
  const API_CACHE = `api-v${VERSION}`;
static/welcome.html CHANGED
@@ -330,26 +330,16 @@
330
  const card = document.getElementById('exploreForm');
331
  card.classList.add('card-loading');
332
 
333
- const success = await autoLoginDemo();
334
- if (success) {
335
- window.location.href = '/?welcome=form';
336
- } else {
337
- // Fallback
338
- window.location.href = '/login?redirect=form';
339
- }
340
  }
341
 
342
  async function exploreTreeMap() {
343
  const card = document.getElementById('exploreMap');
344
  card.classList.add('card-loading');
345
 
346
- const success = await autoLoginDemo();
347
- if (success) {
348
- window.location.href = '/static/map.html?welcome=map';
349
- } else {
350
- // Fallback
351
- window.location.href = '/login?redirect=map';
352
- }
353
  }
354
 
355
  // Enhanced mobile interactions
 
330
  const card = document.getElementById('exploreForm');
331
  card.classList.add('card-loading');
332
 
333
+ // Direct navigation since user is already logged in as demo
334
+ window.location.href = '/app?welcome=form';
 
 
 
 
 
335
  }
336
 
337
  async function exploreTreeMap() {
338
  const card = document.getElementById('exploreMap');
339
  card.classList.add('card-loading');
340
 
341
+ // Direct navigation since user is already logged in as demo
342
+ window.location.href = '/static/map.html?welcome=map';
 
 
 
 
 
343
  }
344
 
345
  // Enhanced mobile interactions
version.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
  "version": "5.1.1",
3
- "timestamp": 1761485558
4
  }
 
1
  {
2
  "version": "5.1.1",
3
+ "timestamp": 1761485777
4
  }