@startanaicompany/cli 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/verify.js +16 -4
- package/src/lib/api.js +2 -2
package/package.json
CHANGED
package/src/commands/verify.js
CHANGED
|
@@ -21,7 +21,7 @@ async function verify(code) {
|
|
|
21
21
|
|
|
22
22
|
const user = getUser();
|
|
23
23
|
|
|
24
|
-
if (!user || !user.
|
|
24
|
+
if (!user || !user.userId) {
|
|
25
25
|
logger.error('No user found. Please register first');
|
|
26
26
|
logger.newline();
|
|
27
27
|
logger.info('Run:');
|
|
@@ -39,17 +39,22 @@ async function verify(code) {
|
|
|
39
39
|
const spin = logger.spinner('Verifying email...').start();
|
|
40
40
|
|
|
41
41
|
try {
|
|
42
|
-
const result = await api.verifyEmail(user.
|
|
42
|
+
const result = await api.verifyEmail(user.userId, code);
|
|
43
43
|
|
|
44
44
|
spin.succeed('Email verified successfully!');
|
|
45
45
|
|
|
46
|
-
// Update user verification status and
|
|
46
|
+
// Update user verification status and save API key
|
|
47
47
|
const updatedUser = {
|
|
48
48
|
...user,
|
|
49
49
|
verified: true,
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// Save API key if returned (only returned once on verification)
|
|
53
|
+
if (result.api_key) {
|
|
54
|
+
updatedUser.apiKey = result.api_key;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// If backend returns session token after verification, update it
|
|
53
58
|
if (result.session_token) {
|
|
54
59
|
updatedUser.sessionToken = result.session_token;
|
|
55
60
|
updatedUser.expiresAt = result.expires_at;
|
|
@@ -61,6 +66,13 @@ async function verify(code) {
|
|
|
61
66
|
logger.success('Your account is now verified!');
|
|
62
67
|
logger.info('You can now create and deploy applications.');
|
|
63
68
|
|
|
69
|
+
// Show API key if provided
|
|
70
|
+
if (result.api_key) {
|
|
71
|
+
logger.newline();
|
|
72
|
+
logger.field('API Key', result.api_key.substring(0, 20) + '...');
|
|
73
|
+
logger.warn('Save your API key securely. It will not be shown again.');
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
// Show expiration if session token was updated
|
|
65
77
|
if (result.expires_at) {
|
|
66
78
|
const expirationDate = new Date(result.expires_at);
|
package/src/lib/api.js
CHANGED
|
@@ -68,10 +68,10 @@ async function register(email) {
|
|
|
68
68
|
/**
|
|
69
69
|
* Verify email with code
|
|
70
70
|
*/
|
|
71
|
-
async function verifyEmail(
|
|
71
|
+
async function verifyEmail(userId, code) {
|
|
72
72
|
const client = createClient();
|
|
73
73
|
const response = await client.post('/users/verify', {
|
|
74
|
-
|
|
74
|
+
user_id: userId,
|
|
75
75
|
verification_code: code,
|
|
76
76
|
});
|
|
77
77
|
return response.data;
|