Skip to content

Commit 09765b4

Browse files
author
Manus AI
committed
fix: Skip prompts when verify options provided and improve error messages
Fixed two UX issues with the verify command: 1. Skip prompts when options are provided - If -e and -c are passed, don't prompt the user - Much better UX when copy/pasting from email 2. Better error handling and debugging - Show actual error messages instead of 'Unknown error' - Added debug logging for API endpoint, request data, and response - Helps diagnose verification issues Now users can simply copy/paste the command from their email and it works without any prompts.
1 parent b71c14c commit 09765b4

1 file changed

Lines changed: 43 additions & 23 deletions

File tree

index.js

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -843,53 +843,73 @@ async function verifyCommand(options) {
843843
console.log('\n📧 Verify Your Registry Developer Account\n');
844844

845845
try {
846-
// Collect verification parameters
847-
const answers = await prompt([
848-
{
849-
type: 'input',
850-
name: 'email',
851-
message: 'Email address:',
852-
initial: options.email,
853-
validate: (value) => value ? true : 'Email is required'
854-
},
855-
{
856-
type: 'input',
857-
name: 'code',
858-
message: 'Verification code (from email):',
859-
initial: options.code,
860-
validate: (value) => value ? true : 'Verification code is required'
861-
}
862-
]);
863-
864-
const email = options.email || answers.email;
865-
const code = options.code || answers.code;
846+
let email = options.email;
847+
let code = options.code;
866848
const host = options.host || 'https://api.fleetbase.io';
867849

850+
// Only prompt if values not provided
851+
if (!email || !code) {
852+
const answers = await prompt([
853+
{
854+
type: 'input',
855+
name: 'email',
856+
message: 'Email address:',
857+
initial: email,
858+
skip: () => !!email,
859+
validate: (value) => value ? true : 'Email is required'
860+
},
861+
{
862+
type: 'input',
863+
name: 'code',
864+
message: 'Verification code (from email):',
865+
initial: code,
866+
skip: () => !!code,
867+
validate: (value) => value ? true : 'Verification code is required'
868+
}
869+
]);
870+
email = email || answers.email;
871+
code = code || answers.code;
872+
}
873+
868874
// Ensure host has protocol
869875
const apiHost = host.startsWith('http://') || host.startsWith('https://')
870876
? host
871877
: `https://${host}`;
872878
const verificationApi = `${apiHost}/~registry/v1/developer-account/verify`;
873879

874880
console.log('\nVerifying account...');
881+
console.log(`API Endpoint: ${verificationApi}`);
882+
console.log(`Email: ${email}`);
883+
console.log(`Code: ${code}`);
875884

876885
// Make API call to verify
877886
const response = await axios.post(verificationApi, {
878887
email: email,
879888
code: code
880889
});
881890

891+
console.log('\n[DEBUG] Response status:', response.status);
892+
console.log('[DEBUG] Response data:', JSON.stringify(response.data, null, 2));
893+
882894
if (response.data.status === 'success') {
883895
console.log('\n✓ Email verified successfully!');
884896
console.log('✓ You can now login with: flb login -u <username>' + (host !== 'https://api.fleetbase.io' ? ` --host ${host}` : ''));
885897
} else {
886-
console.error('Verification failed:', response.data.message || 'Unknown error');
898+
console.error('\nVerification failed:', response.data.message || 'Unknown error');
887899
process.exit(1);
888900
}
889901
} catch (error) {
890-
if (error.response && error.response.data) {
902+
console.error('\n[DEBUG] Error caught:', error.message);
903+
if (error.code) console.error('[DEBUG] Error code:', error.code);
904+
if (error.response) {
905+
console.error('[DEBUG] Response status:', error.response.status);
906+
console.error('[DEBUG] Response data:', JSON.stringify(error.response.data, null, 2));
891907
const errorData = error.response.data;
892-
console.error('\nVerification failed:', errorData.message || 'Unknown error');
908+
console.error('\nVerification failed:', errorData.message || errorData.error || 'Unknown error');
909+
} else if (error.request) {
910+
console.error('[DEBUG] No response received from server');
911+
console.error('[DEBUG] Request was made to:', verificationApi);
912+
console.error('\nVerification failed: No response from server');
893913
} else {
894914
console.error('\nVerification failed:', error.message);
895915
}

0 commit comments

Comments
 (0)