mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-23 21:50:10 +08:00
Modernized disable_twofactor example script
This commit is contained in:
parent
b92c5d852d
commit
3f99c718d4
@ -1,18 +1,19 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
var ReadLine = require('readline');
|
||||
var fs = require('fs');
|
||||
// If you aren't running this script inside of the repository, replace the following line with:
|
||||
// const SteamCommunity = require('steamcommunity');
|
||||
const SteamCommunity = require('../index.js');
|
||||
const ReadLine = require('readline');
|
||||
|
||||
var community = new SteamCommunity();
|
||||
var rl = ReadLine.createInterface({
|
||||
"input": process.stdin,
|
||||
"output": process.stdout
|
||||
let community = new SteamCommunity();
|
||||
let 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);
|
||||
rl.question('Username: ', (accountName) => {
|
||||
rl.question('Password: ', (password) => {
|
||||
rl.question('Two-Factor Auth Code: ', (authCode) =>{
|
||||
rl.question('Revocation Code: R', (rCode) => {
|
||||
doLogin(accountName, password, authCode, '', rCode);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -20,21 +21,21 @@ rl.question("Username: ", function(accountName) {
|
||||
|
||||
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.");
|
||||
accountName: accountName,
|
||||
password: password,
|
||||
twoFactorCode: authCode,
|
||||
captcha: captcha
|
||||
}, (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') {
|
||||
if (err.message == 'CAPTCHA') {
|
||||
console.log(err.captchaurl);
|
||||
rl.question("CAPTCHA: ", function(captchaInput) {
|
||||
rl.question('CAPTCHA: ', (captchaInput) => {
|
||||
doLogin(accountName, password, authCode, captchaInput);
|
||||
});
|
||||
|
||||
@ -46,15 +47,15 @@ function doLogin(accountName, password, authCode, captcha, rCode) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Logged on!");
|
||||
community.disableTwoFactor("R" + rCode, function(err) {
|
||||
if(err) {
|
||||
console.log('Logged on!');
|
||||
community.disableTwoFactor('R' + rCode, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
process.exit();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Two-factor authentication disabled!");
|
||||
console.log('Two-factor authentication disabled!');
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user