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.render",
|
||||
"connect-architect/connect.render.ejs",
|
||||
"connect-architect/connect.redirect",
|
||||
{
|
||||
packagePath: "connect-architect/connect.redirect",
|
||||
trustedDomainsRe: /.*/,
|
||||
},
|
||||
"connect-architect/connect.cors",
|
||||
"./c9.connect.favicon/favicon",
|
||||
// "./c9.logger/stdout-logger",
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
var url = require("url");
|
||||
var assert = require("assert");
|
||||
|
||||
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) {
|
||||
this.writeHead(302, {Location: location});
|
||||
this.setHeader("Location", location);
|
||||
this.writeHead(302);
|
||||
this.end("");
|
||||
});
|
||||
imports.connect.addResponseMethod("secureRedirect", function(location) {
|
||||
|
@ -15,18 +18,19 @@ module.exports = function(options, imports, register) {
|
|||
|
||||
if (!trustedDomainsRe.test(parsedLocation.host))
|
||||
location = parsedLocation.path;
|
||||
|
||||
this.writeHead(302, {Location: location});
|
||||
this.end("");
|
||||
|
||||
this.redirect(location);
|
||||
});
|
||||
imports.connect.addResponseMethod("returnTo", function(req, 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;
|
||||
delete req.session.returnTo;
|
||||
}
|
||||
|
||||
this.redirect(url);
|
||||
this.secureRedirect(url);
|
||||
});
|
||||
imports.connect.addResponseMethod("moved", function(location) {
|
||||
this.writeHead(301, {Location: location});
|
||||
|
|
|
@ -107,20 +107,9 @@ define(function(require, exports, module) {
|
|||
}) || true;
|
||||
}
|
||||
|
||||
function logout(callback) {
|
||||
accessToken = "invalid";
|
||||
loggingIn = false;
|
||||
|
||||
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 logout(redirect) {
|
||||
redirect = redirect || window.location.href;
|
||||
window.location.href = ideBaseUrl + "/api/nc/logout?redirect=" + encodeURIComponent(redirect);
|
||||
}
|
||||
|
||||
function createLoopDetector(count, duration) {
|
||||
|
|
|
@ -137,7 +137,7 @@ define(function(require, exports, module) {
|
|||
|
||||
function signout() {
|
||||
vfsEndpoint.clearCache();
|
||||
auth.logout(function() { location.href = ideBaseUrl; });
|
||||
auth.logout(ideBaseUrl);
|
||||
}
|
||||
|
||||
function onReLogin() {
|
||||
|
@ -147,9 +147,7 @@ define(function(require, exports, module) {
|
|||
"Please hit OK to reload the IDE.",
|
||||
function() {
|
||||
vfsEndpoint.clearCache();
|
||||
auth.logout(function() {
|
||||
document.location.reload();
|
||||
});
|
||||
auth.logout();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue