Skip to content

Commit d46be3d

Browse files
fix(auth): show 'Log out cancelled' when user declines logout confirmation
1 parent 4808903 commit d46be3d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/contentstack-auth/messages/index.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"CLI_AUTH_LOGOUT_DESCRIPTION": "User session logout",
1919
"CLI_AUTH_LOGOUT_FLAG_FORCE": "Force logging out for skipping the confirmation",
2020
"CLI_AUTH_LOGOUT_ALREADY": "You're already logged out",
21+
"CLI_AUTH_LOGOUT_CANCELLED": "Log out cancelled",
2122
"CLI_AUTH_LOGOUT_NO_AUTHORIZATIONS": "No authorizations found",
2223
"CLI_AUTH_LOGOUT_NO_AUTHORIZATIONS_USER": "No authorizations found for current user",
2324
"CLI_AUTH_WHOAMI_LOGGED_IN_AS": "You are currently logged in with email:",

packages/contentstack-auth/src/commands/auth/logout.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
9393
confirm,
9494
isAuthenticated: oauthHandler.isAuthenticated(),
9595
});
96-
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_ALREADY'), this.contextDetails);
96+
const messageKey = confirm === false && oauthHandler.isAuthenticated()
97+
? 'CLI_AUTH_LOGOUT_CANCELLED'
98+
: 'CLI_AUTH_LOGOUT_ALREADY';
99+
log.success(messageHandler.parse(messageKey), this.contextDetails);
97100
}
98101
} catch (error) {
99102
log.debug('Logout failed.', { ...this.contextDetails, error: error.message });

0 commit comments

Comments
 (0)