Prompt for CAPTCHA input in examples if needed (fixes #88)

This commit is contained in:
Alexander Corn 2016-03-18 23:33:30 -04:00
parent 58927dc937
commit 579fc04c1c
2 changed files with 25 additions and 5 deletions

View File

@ -14,12 +14,13 @@ rl.question("Username: ", function(accountName) {
});
});
function doLogin(accountName, password, authCode, twoFactorCode) {
function doLogin(accountName, password, authCode, twoFactorCode, captcha) {
community.login({
"accountName": accountName,
"password": password,
"authCode": authCode,
"twoFactorCode": twoFactorCode
"twoFactorCode": twoFactorCode,
"captcha": captcha
}, function(err, sessionID, cookies, steamguard) {
if(err) {
if(err.message == 'SteamGuardMobile') {
@ -39,6 +40,15 @@ function doLogin(accountName, password, authCode, twoFactorCode) {
return;
}
if(err.message == 'CAPTCHA') {
console.log(err.captchaurl);
rl.question("CAPTCHA: ", function(captchaInput) {
doLogin(accountName, password, authCode, twoFactorCode, captchaInput);
});
return;
}
console.log(err);
process.exit();
return;

View File

@ -14,11 +14,12 @@ rl.question("Username: ", function(accountName) {
});
});
function doLogin(accountName, password, authCode) {
function doLogin(accountName, password, authCode, captcha) {
community.login({
"accountName": accountName,
"password": password,
"authCode": authCode
"authCode": authCode,
"captcha": captcha
}, function(err, sessionID, cookies, steamguard) {
if(err) {
if(err.message == 'SteamGuardMobile') {
@ -29,13 +30,22 @@ function doLogin(accountName, password, authCode) {
if(err.message == 'SteamGuard') {
console.log("An email has been sent to your address at " + err.emaildomain);
rl.question("Steam Guard Code: ", function(code) {
rl.question("Steam Guard Code: ", function (code) {
doLogin(accountName, password, code);
});
return;
}
if(err.message == 'CAPTCHA') {
console.log(err.captchaurl);
rl.question("CAPTCHA: ", function(captchaInput) {
doLogin(accountName, password, authCode, captchaInput);
});
return;
}
console.log(err);
process.exit();
return;