open source is social v-it.org
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'hopper-6da3bzjn-login-polish'

+19 -8
+19 -8
src/cmd/login.js
··· 9 9 program 10 10 .command('login') 11 11 .description('Log in to Bluesky via browser-based OAuth') 12 - .option('--handle <handle>', 'Bluesky handle (e.g. alice.bsky.social)') 12 + .argument('<handle>', 'Bluesky handle (e.g. alice.bsky.social)') 13 13 .option('-v, --verbose', 'Show discovery details') 14 14 .option('--output <file>', 'Save token JSON to file') 15 - .action(async (opts) => { 16 - const { handle, verbose, output } = opts; 15 + .option('--reset', 'Force re-login even if credentials are valid') 16 + .action(async (handle, opts) => { 17 + const { verbose, output, reset } = opts; 18 + handle = handle.replace(/^@/, ''); 19 + 20 + if (!reset) { 21 + const existing = loadConfig(); 22 + if (existing.did && existing.access_token && existing.expires_at) { 23 + const expiresAt = new Date(existing.expires_at).getTime(); 24 + if (expiresAt > Date.now() + 60_000) { 25 + console.log(`Already logged in as ${existing.did}`); 26 + console.log(`Token expires: ${existing.expires_at}`); 27 + return; 28 + } 29 + } 30 + } 31 + 17 32 let server; 18 33 let timeout; 19 34 20 35 try { 21 - if (!handle) { 22 - throw new Error('Missing required --handle argument.'); 23 - } 24 - 25 36 let resolveCallback; 26 37 let callbackResolved = false; 27 38 const callbackPromise = new Promise((resolve) => { ··· 154 165 } 155 166 156 167 if (server) { 157 - server.stop(); 168 + server.stop(true); 158 169 } 159 170 } 160 171 });