zaahpi commited on
Commit
802be1d
·
1 Parent(s): 7e57433

Improve authentication flow for improved user experience

Browse files

Update Replica HTML to prompt user for sign-in if not authenticated, and handle authentication errors more gracefully.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 01ad339d-418c-47f5-be76-423bcdc9b50c
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: dd13dc49-9b6b-4bde-a7ac-b7c67625f68c
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/c6a48625-afd1-4b8b-b95e-595805001e6c/01ad339d-418c-47f5-be76-423bcdc9b50c/fCtRmKG
Replit-Helium-Checkpoint-Created: true

Files changed (1) hide show
  1. replica/index.html +9 -4
replica/index.html CHANGED
@@ -487,13 +487,18 @@
487
  try {
488
  const isSignedIn = await puter.auth.isSignedIn();
489
  if (!isSignedIn) {
490
- // For anonymous use, Puter.js can sometimes work without sign-in for certain models
491
- // but most AI features require an account.
492
- // We'll proceed if they are already signed in, or try to sign in.
493
- console.log("User not signed in to Puter");
 
 
 
494
  }
495
  } catch (e) {
496
  console.error("Puter Auth Error:", e);
 
 
497
  }
498
  }
499
 
 
487
  try {
488
  const isSignedIn = await puter.auth.isSignedIn();
489
  if (!isSignedIn) {
490
+ addChatMessage('ai', "I need you to sign in with Puter to access AI capabilities.");
491
+ await puter.auth.signIn();
492
+ // Re-check after sign in
493
+ if (!await puter.auth.isSignedIn()) {
494
+ addChatMessage('ai', "Authentication failed. Please try again.");
495
+ return;
496
+ }
497
  }
498
  } catch (e) {
499
  console.error("Puter Auth Error:", e);
500
+ addChatMessage('ai', "Authentication failed. Please try again.");
501
+ return;
502
  }
503
  }
504