Skip to content

Commit

Permalink
Fix two-factor authentication problem, close node-gh#240 node-gh#120
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Jan 5, 2014
1 parent 479683d commit ee8103b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/cmds/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ User.createAuthorization = function(opt_callback) {
});

base.github.authorization.create(payload, function(err, res) {
//verify if a two-factor authentication code was missing
if (err && err.message && err.message.indexOf('OTP') > 0) {
inquirer.prompt(
[
{
type: 'input',
message: 'Enter your two-factor code',
name: 'otp'
}
], function(factor) {
payload.headers['X-GitHub-OTP'] = factor.otp;

base.github.authorization.create(payload, function(err, res) {
logger.defaultCallback(err, null, 'Authentication succeed.');

if (res.token) {
base.writeGlobalConfigCredentials(answers.user, res.token);

User.authorize();
}

opt_callback && opt_callback(err);
});
});
return;
}

logger.defaultCallback(err, null, 'Authentication succeed.');

if (res.token) {
Expand Down

0 comments on commit ee8103b

Please sign in to comment.