From eaacef66bb9a10bb841883dc503d7b594bfb44e5 Mon Sep 17 00:00:00 2001 From: Alexander Corn Date: Fri, 17 Jul 2015 21:10:08 -0400 Subject: [PATCH] Added loggedIn method --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index da15e90..8c31fca 100644 --- a/index.js +++ b/index.js @@ -235,6 +235,17 @@ SteamCommunity.prototype.resetItemNotifications = function(callback) { }); }; +SteamCommunity.prototype.loggedIn = function(callback) { + this.request("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) { + if(err || response.statusCode != 302) { + callback(err ? err.message : "HTTP error " + response.statusCode); + return; + } + + callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/)); + }); +}; + SteamCommunity.prototype._checkCommunityError = function(html, callback) { if(html.match(/

Sorry!<\/h1>/)) { var match = html.match(/

(.+)<\/h3>/);