kopia lustrzana https://github.com/c9/core
commit
ca8cd63bc9
|
@ -132,7 +132,10 @@ module.exports = function(config, optimist) {
|
||||||
"connect-architect/connect.remote-address",
|
"connect-architect/connect.remote-address",
|
||||||
"connect-architect/connect.render",
|
"connect-architect/connect.render",
|
||||||
"connect-architect/connect.render.ejs",
|
"connect-architect/connect.render.ejs",
|
||||||
"connect-architect/connect.redirect",
|
{
|
||||||
|
packagePath: "connect-architect/connect.redirect",
|
||||||
|
trustedDomainsRe: /.*/,
|
||||||
|
},
|
||||||
"connect-architect/connect.cors",
|
"connect-architect/connect.cors",
|
||||||
"./c9.connect.favicon/favicon",
|
"./c9.connect.favicon/favicon",
|
||||||
// "./c9.logger/stdout-logger",
|
// "./c9.logger/stdout-logger",
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var url = require("url");
|
var url = require("url");
|
||||||
|
var assert = require("assert");
|
||||||
|
|
||||||
module.exports = function(options, imports, register) {
|
module.exports = function(options, imports, register) {
|
||||||
|
assert(options.trustedDomainsRe, "Options 'trustedDomainsRe' must be set");
|
||||||
|
|
||||||
var trustedDomainsRe = options.trustedDomainsRe || /.*/;
|
var trustedDomainsRe = options.trustedDomainsRe;
|
||||||
|
|
||||||
imports.connect.addResponseMethod("redirect", function(location) {
|
imports.connect.addResponseMethod("redirect", function(location) {
|
||||||
this.writeHead(302, {Location: location});
|
this.setHeader("Location", location);
|
||||||
|
this.writeHead(302);
|
||||||
this.end("");
|
this.end("");
|
||||||
});
|
});
|
||||||
imports.connect.addResponseMethod("secureRedirect", function(location) {
|
imports.connect.addResponseMethod("secureRedirect", function(location) {
|
||||||
|
@ -15,18 +18,19 @@ module.exports = function(options, imports, register) {
|
||||||
|
|
||||||
if (!trustedDomainsRe.test(parsedLocation.host))
|
if (!trustedDomainsRe.test(parsedLocation.host))
|
||||||
location = parsedLocation.path;
|
location = parsedLocation.path;
|
||||||
|
|
||||||
this.writeHead(302, {Location: location});
|
this.redirect(location);
|
||||||
this.end("");
|
|
||||||
});
|
});
|
||||||
imports.connect.addResponseMethod("returnTo", function(req, defaultReturn) {
|
imports.connect.addResponseMethod("returnTo", function(req, defaultReturn) {
|
||||||
var url = defaultReturn || "/";
|
var url = defaultReturn || "/";
|
||||||
if (req.session && req.session.returnTo) {
|
if (req.parsedUrl && req.parsedUrl.query.redirect) {
|
||||||
|
url = req.parsedUrl.query.redirect;
|
||||||
|
}
|
||||||
|
else if (req.session && req.session.returnTo) {
|
||||||
url = req.session.returnTo;
|
url = req.session.returnTo;
|
||||||
delete req.session.returnTo;
|
delete req.session.returnTo;
|
||||||
}
|
}
|
||||||
|
this.secureRedirect(url);
|
||||||
this.redirect(url);
|
|
||||||
});
|
});
|
||||||
imports.connect.addResponseMethod("moved", function(location) {
|
imports.connect.addResponseMethod("moved", function(location) {
|
||||||
this.writeHead(301, {Location: location});
|
this.writeHead(301, {Location: location});
|
||||||
|
|
|
@ -107,20 +107,9 @@ define(function(require, exports, module) {
|
||||||
}) || true;
|
}) || true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout(callback) {
|
function logout(redirect) {
|
||||||
accessToken = "invalid";
|
redirect = redirect || window.location.href;
|
||||||
loggingIn = false;
|
window.location.href = ideBaseUrl + "/api/nc/logout?redirect=" + encodeURIComponent(redirect);
|
||||||
|
|
||||||
http.request("/_auth/logout", function(err1) {
|
|
||||||
http.request(ideBaseUrl + "/auth/signout", {
|
|
||||||
method: "POST",
|
|
||||||
withCredentials: true
|
|
||||||
}, function(err2) {
|
|
||||||
loggedIn = false;
|
|
||||||
emit("logout", {uid: uid, newUid: ANONYMOUS});
|
|
||||||
callback && callback(err1 || err2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createLoopDetector(count, duration) {
|
function createLoopDetector(count, duration) {
|
||||||
|
|
|
@ -137,7 +137,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
function signout() {
|
function signout() {
|
||||||
vfsEndpoint.clearCache();
|
vfsEndpoint.clearCache();
|
||||||
auth.logout(function() { location.href = ideBaseUrl; });
|
auth.logout(ideBaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onReLogin() {
|
function onReLogin() {
|
||||||
|
@ -147,9 +147,7 @@ define(function(require, exports, module) {
|
||||||
"Please hit OK to reload the IDE.",
|
"Please hit OK to reload the IDE.",
|
||||||
function() {
|
function() {
|
||||||
vfsEndpoint.clearCache();
|
vfsEndpoint.clearCache();
|
||||||
auth.logout(function() {
|
auth.logout();
|
||||||
document.location.reload();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue