diff --git a/index.js b/index.js index 54d028d..17c73b7 100644 --- a/index.js +++ b/index.js @@ -65,7 +65,7 @@ SteamCommunity.prototype.login = function(details, callback) { this._setCookie(Request.cookie('steamMachineAuth' + parts[0] + '=' + encodeURIComponent(parts[1])), true); } - var disableMobile = details.disableMobile; + var disableMobile = typeof details.disableMobile == 'undefined' ? true : details.disableMobile; var self = this; @@ -123,7 +123,7 @@ SteamCommunity.prototype.login = function(details, callback) { "donotcache": Date.now() }; - if(!disableMobile){ + if (!disableMobile) { formObj.oauth_client_id = "DE45CD61"; formObj.oauth_scope = "read_profile write_profile read_client write_client"; formObj.loginfriendlyname = "#login_emailauth_friendlyname_mobile"; @@ -161,22 +161,20 @@ SteamCommunity.prototype.login = function(details, callback) { callback(error); } else if (!body.success) { callback(new Error(body.message || "Unknown error")); - } else if (!disableMobile && !body.oauth) { - callback(new Error("Malformed response")); } else { var sessionID = generateSessionID(); - var oAuth; + var oAuth = {}; self._setCookie(Request.cookie('sessionid=' + sessionID)); var cookies = self._jar.getCookieString("https://steamcommunity.com").split(';').map(function(cookie) { return cookie.trim(); }); - if (!disableMobile){ + if (!disableMobile && body.oauth) { oAuth = JSON.parse(body.oauth); self.steamID = new SteamID(oAuth.steamid); self.oAuthToken = oAuth.oauth_token; - }else{ + } else { for(var i = 0; i < cookies.length; i++) { var parts = cookies[i].split('='); if(parts[0] == 'steamLogin') { @@ -190,7 +188,7 @@ SteamCommunity.prototype.login = function(details, callback) { // Find the Steam Guard cookie var steamguard = null; - for(var i = 0; i < cookies.length; i++) { + for (var i = 0; i < cookies.length; i++) { var parts = cookies[i].split('='); if(parts[0] == 'steamMachineAuth' + self.steamID) { steamguard = self.steamID.toString() + '||' + decodeURIComponent(parts[1]);