Skip to content

Commit

Permalink
Login can reuse existing session key
Browse files Browse the repository at this point in the history
  • Loading branch information
jahwag committed Aug 22, 2024
1 parent b2eeae5 commit 2cbc572
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/claudesync/cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,28 @@ def login(ctx, provider):
)
return
provider_instance = get_provider(provider)
session = provider_instance.login()
config.set_session_key(session[0], session[1])
config.set("active_provider", provider)
click.echo("Logged in successfully.")

# Check for existing valid session key
existing_session_key = config.get_session_key()
existing_session_key_expiry = config.get("session_key_expiry")

if existing_session_key and existing_session_key_expiry:
use_existing = click.confirm(
"An existing session key was found. Would you like to use it?", default=True
)
if use_existing:
config.set("active_provider", provider)
click.echo("Logged in successfully using existing session key.")
else:
session = provider_instance.login()
config.set_session_key(session[0], session[1])
config.set("active_provider", provider)
click.echo("Logged in successfully with new session key.")
else:
session = provider_instance.login()
config.set_session_key(session[0], session[1])
config.set("active_provider", provider)
click.echo("Logged in successfully.")

# Automatically run organization select
ctx.invoke(org_select)
Expand Down

0 comments on commit 2cbc572

Please sign in to comment.