Remember Steam login so that cookies don't expire if logged in elsewhere

This commit is contained in:
Alexander Corn 2015-06-24 13:31:01 -04:00
parent eb2081c325
commit 2a758fc180

View File

@ -46,35 +46,31 @@ SteamCommunity.prototype.login = function(details, callback) {
"emailsteamid": "", "emailsteamid": "",
"loginfriendlyname": "", "loginfriendlyname": "",
"password": hex2b64(key.encrypt(details.password)), "password": hex2b64(key.encrypt(details.password)),
"remember_login": false, "remember_login": "true",
"rsatimestamp": json.timestamp, "rsatimestamp": json.timestamp,
"twofactorcode": "", "twofactorcode": "",
"username": details.accountName "username": details.accountName
}; };
self.request.post("https://steamcommunity.com/login/dologin/", {"form": form}, function(err, response, body) { self.request.post({
"uri": "https://steamcommunity.com/login/dologin/",
"json": true,
"form": form
}, function(err, response, body) {
if(err) { if(err) {
callback(err); callback(err);
return; return;
} }
var json; if(!body.success && body.emailauth_needed) {
try { callback("Please provide the authorization code sent to your address at " + body.emaildomain);
json = JSON.parse(body); } else if(!body.success) {
} catch(e) { callback(body.message || "Unknown error");
callback(e);
return;
}
if(!json.success && json.emailauth_needed) {
callback("Please provide the authorization code sent to your address at " + json.emaildomain);
} else if(!json.success) {
callback(json.message || "Unknown error");
} else { } else {
var sessionID = generateSessionID(); var sessionID = generateSessionID();
self._jar.setCookie(Request.cookie('sessionid=' + sessionID), 'http://steamcommunity.com'); self._jar.setCookie(Request.cookie('sessionid=' + sessionID), 'http://steamcommunity.com');
self.steamID = new SteamID(json.transfer_parameters.steamid); self.steamID = new SteamID(body.transfer_parameters.steamid);
var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) { var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) {
return cookie.trim(); return cookie.trim();
}); });