Skip to content

Commit

Permalink
[fix] saves auth token instead of password. Fixes #371 and #302
Browse files Browse the repository at this point in the history
  • Loading branch information
julianduque committed Feb 7, 2013
1 parent 23e6821 commit 6b2cadd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/jitsu/commands.js
Expand Up @@ -4,22 +4,38 @@
* (C) 2010, Nodejitsu Inc.
*
*/

var jitsu = require('../jitsu');

jitsu.use(require('flatiron-cli-users'), {
before: {
login: function (details) {
login: function (details, next) {
if (!details || !details.username) {
jitsu.log.warn('Login is required to continue');
jitsu.log.info('To login, an activated nodejitsu account is required');
jitsu.log.help('To create a new account use the ' + 'jitsu signup'.magenta + ' command');
}
next();
}
},
after: {
create: function (details) {
jitsu.log.help('Please check for an email sent to ' + details.email.grey + ' for further activation instructions.');
},
login: function (details, next) {
//
// Check if the user has webops token and replace the password with it
//
if (details && details.username) {
jitsu.tokens.list(details.username, function(err, results) {
if(!err && results && results.apiTokens && results.apiTokens.webops) {
var token = results.apiTokens.webops;
jitsu.config.set('password', token);
jitsu.config.save();
return next();
}
});
}
}
}
});

0 comments on commit 6b2cadd

Please sign in to comment.