Skip to content

Commit b71c14c

Browse files
author
Manus AI
committed
feat: Add verify command and improve registration UX
Added new 'flb verify' command to verify developer account emails: - Interactive prompts for email and verification code - Supports --host parameter for self-hosted instances - Clear success/error messages Updated registration success message: - Shows verification code was sent - Displays exact verify command to run - Guides user through next steps This makes the verification flow much clearer for users.
1 parent 037434b commit b71c14c

1 file changed

Lines changed: 73 additions & 3 deletions

File tree

index.js

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,12 @@ async function registerCommand(options) {
796796

797797
if (response.data.status === 'success') {
798798
console.log('\n✓ Account created successfully!');
799-
console.log('✓ Please check your email to verify your account.');
800-
const loginCmd = options.host ? `flb login -u ${registrationData.username} --host ${options.host}` : `flb login -u ${registrationData.username}`;
801-
console.log(`\n✓ Once verified, you can login with: ${loginCmd}`);
799+
console.log('✓ A verification code has been sent to your email.');
800+
console.log('\n👉 Next step: Verify your email address');
801+
const verifyCmd = `flb verify -e ${registrationData.email}` + (host !== 'https://api.fleetbase.io' ? ` --host ${host}` : '');
802+
console.log(` Run: ${verifyCmd}`);
803+
const loginCmd = `flb login -u ${registrationData.username}` + (host !== 'https://api.fleetbase.io' ? ` --host ${host}` : '');
804+
console.log(`\n✓ After verification, login with: ${loginCmd}`);
802805
} else {
803806
console.error('Registration failed:', response.data.message || 'Unknown error');
804807
process.exit(1);
@@ -835,6 +838,65 @@ async function registerCommand(options) {
835838
}
836839
}
837840

841+
// Command to verify developer account email
842+
async function verifyCommand(options) {
843+
console.log('\n📧 Verify Your Registry Developer Account\n');
844+
845+
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;
866+
const host = options.host || 'https://api.fleetbase.io';
867+
868+
// Ensure host has protocol
869+
const apiHost = host.startsWith('http://') || host.startsWith('https://')
870+
? host
871+
: `https://${host}`;
872+
const verificationApi = `${apiHost}/~registry/v1/developer-account/verify`;
873+
874+
console.log('\nVerifying account...');
875+
876+
// Make API call to verify
877+
const response = await axios.post(verificationApi, {
878+
email: email,
879+
code: code
880+
});
881+
882+
if (response.data.status === 'success') {
883+
console.log('\n✓ Email verified successfully!');
884+
console.log('✓ You can now login with: flb login -u <username>' + (host !== 'https://api.fleetbase.io' ? ` --host ${host}` : ''));
885+
} else {
886+
console.error('Verification failed:', response.data.message || 'Unknown error');
887+
process.exit(1);
888+
}
889+
} catch (error) {
890+
if (error.response && error.response.data) {
891+
const errorData = error.response.data;
892+
console.error('\nVerification failed:', errorData.message || 'Unknown error');
893+
} else {
894+
console.error('\nVerification failed:', error.message);
895+
}
896+
process.exit(1);
897+
}
898+
}
899+
838900
// Command to install Fleetbase via Docker
839901
async function installFleetbaseCommand(options) {
840902
const crypto = require('crypto');
@@ -1202,6 +1264,14 @@ program
12021264
.option('-h, --host <host>', 'API host with protocol (default: https://api.fleetbase.io)')
12031265
.action(registerCommand);
12041266

1267+
program
1268+
.command('verify')
1269+
.description('Verify your Registry Developer Account email')
1270+
.option('-e, --email <email>', 'Email address')
1271+
.option('-c, --code <code>', 'Verification code from email')
1272+
.option('-h, --host <host>', 'API host with protocol (default: https://api.fleetbase.io)')
1273+
.action(verifyCommand);
1274+
12051275
program
12061276
.command('install-fleetbase')
12071277
.description('Install Fleetbase using Docker')

0 commit comments

Comments
 (0)