mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-14 04:42:55 +08:00
Added disable_twofactor example
This commit is contained in:
parent
64aaca66be
commit
ddf0221489
61
examples/disable_twofactor.js
Normal file
61
examples/disable_twofactor.js
Normal file
@ -0,0 +1,61 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
var ReadLine = require('readline');
|
||||
var fs = require('fs');
|
||||
|
||||
var community = new SteamCommunity();
|
||||
var rl = ReadLine.createInterface({
|
||||
"input": process.stdin,
|
||||
"output": process.stdout
|
||||
});
|
||||
|
||||
rl.question("Username: ", function(accountName) {
|
||||
rl.question("Password: ", function(password) {
|
||||
rl.question("Two-Factor Auth Code: ", function(authCode) {
|
||||
rl.question("Revocation Code: R", function(rCode) {
|
||||
doLogin(accountName, password, authCode, "", rCode);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function doLogin(accountName, password, authCode, captcha, rCode) {
|
||||
community.login({
|
||||
"accountName": accountName,
|
||||
"password": password,
|
||||
"twoFactorCode": authCode,
|
||||
"captcha": captcha
|
||||
}, function(err, sessionID, cookies, steamguard) {
|
||||
if(err) {
|
||||
if(err.message == 'SteamGuard') {
|
||||
console.log("This account does not have two-factor authentication enabled.");
|
||||
process.exit();
|
||||
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;
|
||||
}
|
||||
|
||||
console.log("Logged on!");
|
||||
community.disableTwoFactor("R" + rCode, function(err) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
process.exit();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Two-factor authentication disabled!");
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user