Skip to content

Commit

Permalink
[minor] Check that username is non-blank before trying to list apps, …
Browse files Browse the repository at this point in the history
…and automatically run the login step
  • Loading branch information
jfhbrook committed Sep 3, 2012
1 parent 92bcbde commit 8070762
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/jitsu/commands/apps.js
Expand Up @@ -285,20 +285,22 @@ apps.list = function (username, callback) {
username = username || authuser;
}

if (authuser === '') {
return jitsu.commands.users.login(function (err) {
if (err) {
return callback(err);
}

jitsu.commands.apps.list(username, callback);
});
}

jitsu.log.info('Listing all apps for ' + username.magenta);

jitsu.apps.list(username, function (err, apps) {
jitsu.apps.list(username, function cb(err, apps) {
if (err) {
if (err.statusCode === 403) {
if (authuser === '') {
jitsu.log.error('');
jitsu.log.error('jitsu is not logged in and cannot list applications');
jitsu.log.error('Try running ' + 'jitsu login'.magenta);
jitsu.log.error('');
}
else {
jitsu.log.error(jitsu.config.get('username').magenta + ' is not authorized to list applications for user: ' + username.magenta);
}
jitsu.log.error(jitsu.config.get('username').magenta + ' is not authorized to list applications for user: ' + username.magenta);
}
return callback(err);
}
Expand Down

0 comments on commit 8070762

Please sign in to comment.