Skip to content

Commit

Permalink
[minor] Added reset property with defaults and better message
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Aug 12, 2011
1 parent 3574246 commit 5c9b510
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/jitsu.js
Expand Up @@ -225,6 +225,19 @@ jitsu.setupUserNoWarn = function(callback) {
//
var tries = 0;

function offerReset (username) {
jitsu.prompt.get(['reset'], function (err, res) {
if (err) {
return callback(err);
}
if (/^y[es]*/i.test(res.reset)) {
return jitsu.commands.run(['users', 'forgot', username], callback);
}

callback(new Error('Invalid username / password.'));
});
}

(function setupAuth () {
jitsu.prompt.get(['username', 'password'], function (err, result) {
if (err) {
Expand Down Expand Up @@ -256,19 +269,6 @@ jitsu.setupUserNoWarn = function(callback) {
});
});
})();

function offerReset(username) {
jitsu.prompt.get(['reset'], function (err, res) {
if (err) {
return callback(err);
}
if (/^y[es]*/i.test(res.reset)) {
return jitsu.commands.run(['users', 'forgot', username], callback);
}
return callback(new Error('Password Reset Pending.'));
});
}

};

//
Expand Down
6 changes: 6 additions & 0 deletions lib/jitsu/properties.js
Expand Up @@ -36,5 +36,11 @@ properties.properties = {
name: 'username',
validator: /^[\w|\-]+$/,
warning: 'Username can only be letters, numbers, and dashes'
},
reset: {
name: 'request password reset',
validator: /y[es]?|n[o]?/,
warning: 'Must respond yes or no',
default: 'no'
}
};

0 comments on commit 5c9b510

Please sign in to comment.