Fix signout for IDE

pull/137/head
Nikolai Onken 2015-08-20 13:56:38 +00:00
rodzic 59b011507c
commit bc56c35800
3 zmienionych plików z 20 dodań i 2 usunięć

Wyświetl plik

@ -11,6 +11,7 @@ module.exports = function(options, imports, register) {
function cors(origin, options) {
return function(req, res, next) {
options = options || {};
var whitelist = options.whitelist || [];
var writeHead = res.writeHead;
res.writeHead = function(status, headers) {
@ -20,6 +21,18 @@ function cors(origin, options) {
if (key.toLowerCase().indexOf("access-control") === 0)
delete(headers[key]);
if (req.headers.origin) {
var hasHostName = whitelist.some(function(hostname) {
return req.headers.origin.match(new RegExp(hostname.replace(".", "\\.") + "$"));
});
if (whitelist.length && !hasHostName)
return writeHead.call(res, status, headers);
if (hasHostName)
origin = req.headers.origin;
}
headers["Access-Control-Allow-Origin"] = origin;
headers["Access-Control-Allow-Methods"] = options.methods || "GET, OPTIONS";
if (options.headers)
@ -38,7 +51,7 @@ function cors(origin, options) {
res.end();
return;
}
next();
};
}

Wyświetl plik

@ -78,6 +78,10 @@ define(function(require, module, exports) {
}
}
if (options.withCredentials) {
xhr.withCredentials = true;
}
var timer;
var timedout = false;
if (timeout) {

Wyświetl plik

@ -113,7 +113,8 @@ define(function(require, exports, module) {
http.request("/_auth/logout", function(err1) {
http.request(ideBaseUrl + "/auth/signout", {
method: "POST"
method: "POST",
withCredentials: true
}, function(err2) {
loggedIn = false;
emit("logout", {uid: uid, newUid: ANONYMOUS});