From 043984c8e1dc2ea96cca39f25f8971395fe49efe Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 19 Oct 2015 17:22:19 +0200 Subject: [PATCH] Revert "Put user content on a different domain" --- node_modules/c9/object.js | 9 --------- node_modules/c9/string.js | 9 --------- node_modules/c9/urls.js | 14 ++++---------- plugins/c9.preview/preview.handler.js | 13 +++---------- server.js | 10 ++++++---- 5 files changed, 13 insertions(+), 42 deletions(-) delete mode 100644 node_modules/c9/object.js diff --git a/node_modules/c9/object.js b/node_modules/c9/object.js deleted file mode 100644 index 875dc338..00000000 --- a/node_modules/c9/object.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Swap keys and values of an object - */ -exports.invert = function(obj) { - return Object.keys(obj).reduce(function(res, key) { - res[obj[key]] = key; - return res; - }, {}); -}; \ No newline at end of file diff --git a/node_modules/c9/string.js b/node_modules/c9/string.js index 2a28f65c..5e3714ce 100644 --- a/node_modules/c9/string.js +++ b/node_modules/c9/string.js @@ -43,14 +43,5 @@ exports.repeat = function(str, times) { exports.count = function(str, substr){ return str.split(substr).length - 1; }; - -exports.endsWith = function(subjectString, searchString, position) { - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; -}; }); \ No newline at end of file diff --git a/node_modules/c9/urls.js b/node_modules/c9/urls.js index 8f5fc472..a1b000af 100644 --- a/node_modules/c9/urls.js +++ b/node_modules/c9/urls.js @@ -22,14 +22,6 @@ function main(options, imports, register) { }); } -plugin.getHost = function(req) { - return (req.headers && req.headers.host - || req.host - || req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1") - || req - ); -}; - /** * Get a desired base URL, given some context. * @@ -38,8 +30,10 @@ plugin.getHost = function(req) { * @param {String} targetBaseUrlPattern The target URL pattern, e.g. https://$DOMAIN */ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) { - var sourceHost = plugin.getHost(req); - + var sourceHost = req.headers && req.headers.host + || req.host + || req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1") + || req; if (typeof sourceHost !== "string") throw new Error("Not a valid request object: " + req); if (!sourceBaseUrlPattern) diff --git a/plugins/c9.preview/preview.handler.js b/plugins/c9.preview/preview.handler.js index 3bf1f351..d59b24bd 100644 --- a/plugins/c9.preview/preview.handler.js +++ b/plugins/c9.preview/preview.handler.js @@ -39,13 +39,7 @@ define(function(require, exports, module) { session.ws = {}; req.projectSession = session.ws[ws]; - - if ( - !req.projectSession || - !req.projectSession.expires || - req.projectSession.expires <= Date.now() || - req.projectSession.uid != req.user.id - ) { + if (!req.projectSession || !req.projectSession.expires || req.projectSession.expires <= Date.now()) { req.projectSession = session.ws[ws] = { expires: Date.now() + 10000 }; @@ -83,7 +77,6 @@ define(function(require, exports, module) { } req.projectSession.role = role; req.projectSession.pid = project.id; - req.projectSession.uid = req.user.id; var type = project.scm; req.projectSession.type = type; @@ -144,8 +137,8 @@ define(function(require, exports, module) { var path = req.params.path; var url = req.proxyUrl + path; - if (req.user.code) - url += "?access_token=" + encodeURIComponent(req.user.code); + if (req.session.token) + url += "?access_token=" + encodeURIComponent(req.session.token.id || req.session.token); var parsedUrl = parseUrl(url); var httpModule = parsedUrl.protocol == "https:" ? https : http; diff --git a/server.js b/server.js index 3c8463e9..2711230c 100755 --- a/server.js +++ b/server.js @@ -23,12 +23,14 @@ var DEFAULT_CONFIG = "s"; var DEFAULT_SETTINGS = getDefaultSettings(); var shortcuts = { - "dev" : ["ide", "preview", "user-content", "vfs", "api", "sapi", "proxy", "redis", "profile", "oldclient", "homepage", "apps-proxy", "-s", "devel"], - "odev" : ["ide", "preview", "user-content", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "worker", "-s", "onlinedev"], - "beta" : ["ide", "preview", "user-content", "vfs", "proxy", "-s", "beta"], + "dev" : ["ide", "preview", "vfs", "api", "sapi", "proxy", "redis", "profile", "oldclient", "homepage", "apps-proxy", "-s", "devel"], + "odev" : ["ide", "preview", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "worker", "-s", "onlinedev"], + "bill" : ["ide", "preview", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "-s", "billing"], + "beta" : ["ide", "preview", "vfs", "proxy", "-s", "beta"], + "ci" : ["ide", "preview", "vfs", "proxy", "-s", "ci"], "s" : ["standalone", "-s", "standalone"] }; -var delayLoadConfigs = ["preview", "user-content", "api", "oldclient", "apps-proxy", "worker"]; +var delayLoadConfigs = ["preview", "api", "oldclient", "apps-proxy", "worker"]; module.exports = main;