Skip to content

Commit 62d596f

Browse files
committed
Fix: Moved the OTP asking to catch block
1 parent 5d4a2e9 commit 62d596f

8 files changed

Lines changed: 544 additions & 557 deletions

File tree

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: 21d5e66a045c155578dc6b6d747745b94c4591c1e17f5226b94b833a46ee9bff
3+
checksum: 402af4afadadbabb915ddaf099cbe0bd94dc571926db4e65d7c44f9d85240e62
44
- filename: pnpm-lock.yaml
55
checksum: a0e789a97a39aece1d637ed121bb6847d39dfb9033b71ea8bf10619eec2e246a
66
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts

package-lock.json

Lines changed: 530 additions & 529 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-auth",
33
"description": "Contentstack CLI plugin for authentication activities",
4-
"version": "1.7.0",
4+
"version": "1.7.1",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {

packages/contentstack-auth/src/utils/auth-handler.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ class AuthHandler {
118118
if (result.user) {
119119
log.debug('Login successful, user found', { module: 'auth-handler', userEmail: result.user.email });
120120
resolve(result.user as User);
121-
} else if (result.error_code === 294) {
121+
}
122+
})
123+
.catch(async (error: any) => {
124+
if (error.errorCode === 294) {
122125
const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);
123-
124126
try {
125127
resolve(await this.login(email, password, tfToken));
126128
} catch (error) {
@@ -129,14 +131,12 @@ class AuthHandler {
129131
reject(error);
130132
}
131133
} else {
132-
log.debug('Login failed: no user found.', { module: 'auth-handler', result });
134+
log.debug('Login failed: no user found.', { module: 'auth-handler', error });
133135
reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
136+
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
137+
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
138+
handleAndLogError(error, { module: 'auth-handler' });
134139
}
135-
})
136-
.catch((error: any) => {
137-
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
138-
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
139-
handleAndLogError(error, { module: 'auth-handler' });
140140
});
141141
} else {
142142
const hasEmail = !!email;

packages/contentstack-auth/src/utils/mfa-handler.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,6 @@ class MFAHandler {
8787
}
8888
}
8989

90-
if (!secret) {
91-
log.debug('Checking stored MFA secret', { module: 'mfa-handler' });
92-
const mfaConfig = configHandler.get('mfa');
93-
if (mfaConfig?.secret) {
94-
try {
95-
secret = this.encrypter.decrypt(mfaConfig.secret);
96-
source = 'stored configuration';
97-
} catch (error) {
98-
log.debug('Failed to decrypt stored MFA secret', { module: 'mfa-handler', error });
99-
handleAndLogError(error, { module: 'mfa-handler' }, messageHandler.parse('CLI_AUTH_MFA_DECRYPT_FAILED'));
100-
}
101-
}
102-
}
103-
10490
if (secret) {
10591
try {
10692
const code = this.generateMFACode(secret);

packages/contentstack-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"winston": "^3.17.0"
2222
},
2323
"devDependencies": {
24-
"@contentstack/cli-auth": "~1.7.0",
24+
"@contentstack/cli-auth": "~1.7.1",
2525
"@contentstack/cli-config": "~1.17.0",
2626
"@contentstack/cli-dev-dependencies": "~1.3.1",
2727
"@oclif/plugin-help": "^6.2.28",

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@contentstack/cli-audit": "~1.17.0",
2626
"@contentstack/cli-cm-export": "~1.23.0",
2727
"@contentstack/cli-cm-import": "~1.31.0",
28-
"@contentstack/cli-auth": "~1.7.0",
28+
"@contentstack/cli-auth": "~1.7.1",
2929
"@contentstack/cli-cm-bootstrap": "~1.18.0",
3030
"@contentstack/cli-cm-branches": "~1.6.2",
3131
"@contentstack/cli-cm-bulk-publish": "~1.10.5",

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)