implement new user content auth for preview

pull/223/head
Fabian Jakobs 2015-10-12 12:22:25 +00:00
rodzic e61b2b12c3
commit 27eaa5add5
1 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -39,7 +39,13 @@ define(function(require, exports, module) {
session.ws = {};
req.projectSession = session.ws[ws];
if (!req.projectSession || !req.projectSession.expires || req.projectSession.expires <= Date.now()) {
if (
!req.projectSession ||
!req.projectSession.expires ||
req.projectSession.expires <= Date.now() ||
req.projectSession.uid != req.user.id
) {
req.projectSession = session.ws[ws] = {
expires: Date.now() + 10000
};
@ -77,6 +83,7 @@ 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;
@ -137,8 +144,8 @@ define(function(require, exports, module) {
var path = req.params.path;
var url = req.proxyUrl + path;
if (req.session.token)
url += "?access_token=" + encodeURIComponent(req.session.token.id || req.session.token);
if (req.user.code)
url += "?access_token=" + encodeURIComponent(req.user.code);
var parsedUrl = parseUrl(url);
var httpModule = parsedUrl.protocol == "https:" ? https : http;