Commit 976ca8a4 authored by Aurelien Vermylen's avatar Aurelien Vermylen

Make credentials possible in ERP5Storage for nodejs use.

parent d1895b24
......@@ -11368,7 +11368,7 @@ return new Parser;
/*jslint nomen: true, unparam: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery*/
SimpleQuery, ComplexQuery, btoa*/
(function (jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery) {
......@@ -11381,8 +11381,9 @@ return new Parser;
"type": "GET",
"url": storage._url,
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (event) {
......@@ -11407,8 +11408,9 @@ return new Parser;
view: options._view
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(undefined, function (error) {
......@@ -11506,6 +11508,13 @@ return new Parser;
}
this._url = spec.url;
this._default_view_reference = spec.default_view_reference;
this._headers = {};
this._withCredentials = true;
if (spec.login !== undefined && spec.password !== undefined) {
this._headers = {"Authorization": "Basic "
+ btoa(spec.login + ":" + spec.password)};
this._withCredentials = false;
}
}
function convertJSONToGet(json) {
......@@ -11543,8 +11552,9 @@ return new Parser;
url: site_hal._actions.add.href,
data: form_data,
xhrFields: {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (evt) {
......@@ -11658,6 +11668,7 @@ return new Parser;
return new RSVP.Queue()
.push(function () {
var start,
k,
end,
range,
request_options = {
......@@ -11665,7 +11676,7 @@ return new Parser;
"dataType": "blob",
"url": action,
"xhrFields": {
withCredentials: true
withCredentials: this._withCredentials
}
};
if (options.start !== undefined || options.end !== undefined) {
......@@ -11687,6 +11698,11 @@ return new Parser;
range = "bytes=" + start + "-" + end;
}
request_options.headers = {Range: range};
for (k in this._headers) {
if (this._headers.hasOwnProperty(k)) {
request_options.headers[k] = this._headers[k];
}
}
}
return jIO.util.ajax(request_options);
})
......@@ -11746,8 +11762,9 @@ return new Parser;
"data": data,
"dataType": "blob",
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
});
};
......@@ -11864,8 +11881,9 @@ return new Parser;
local_roles: local_roles
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (response) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4268,7 +4268,7 @@ return new Parser;
/*jslint nomen: true, unparam: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery*/
SimpleQuery, ComplexQuery, btoa*/
(function (jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery) {
......@@ -4281,8 +4281,9 @@ return new Parser;
"type": "GET",
"url": storage._url,
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (event) {
......@@ -4307,8 +4308,9 @@ return new Parser;
view: options._view
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(undefined, function (error) {
......@@ -4406,6 +4408,13 @@ return new Parser;
}
this._url = spec.url;
this._default_view_reference = spec.default_view_reference;
this._headers = {};
this._withCredentials = true;
if (spec.login !== undefined && spec.password !== undefined) {
this._headers = {"Authorization": "Basic "
+ btoa(spec.login + ":" + spec.password)};
this._withCredentials = false;
}
}
function convertJSONToGet(json) {
......@@ -4443,8 +4452,9 @@ return new Parser;
url: site_hal._actions.add.href,
data: form_data,
xhrFields: {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (evt) {
......@@ -4558,6 +4568,7 @@ return new Parser;
return new RSVP.Queue()
.push(function () {
var start,
k,
end,
range,
request_options = {
......@@ -4565,7 +4576,7 @@ return new Parser;
"dataType": "blob",
"url": action,
"xhrFields": {
withCredentials: true
withCredentials: this._withCredentials
}
};
if (options.start !== undefined || options.end !== undefined) {
......@@ -4587,6 +4598,11 @@ return new Parser;
range = "bytes=" + start + "-" + end;
}
request_options.headers = {Range: range};
for (k in this._headers) {
if (this._headers.hasOwnProperty(k)) {
request_options.headers[k] = this._headers[k];
}
}
}
return jIO.util.ajax(request_options);
})
......@@ -4646,8 +4662,9 @@ return new Parser;
"data": data,
"dataType": "blob",
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
});
};
......@@ -4764,8 +4781,9 @@ return new Parser;
local_roles: local_roles
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (response) {
......
......@@ -11,7 +11,7 @@
/*jslint nomen: true, unparam: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery*/
SimpleQuery, ComplexQuery, btoa*/
(function (jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery) {
......@@ -24,8 +24,9 @@
"type": "GET",
"url": storage._url,
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (event) {
......@@ -50,8 +51,9 @@
view: options._view
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(undefined, function (error) {
......@@ -149,6 +151,13 @@
}
this._url = spec.url;
this._default_view_reference = spec.default_view_reference;
this._headers = {};
this._withCredentials = true;
if (spec.login !== undefined && spec.password !== undefined) {
this._headers = {"Authorization": "Basic "
+ btoa(spec.login + ":" + spec.password)};
this._withCredentials = false;
}
}
function convertJSONToGet(json) {
......@@ -186,8 +195,9 @@
url: site_hal._actions.add.href,
data: form_data,
xhrFields: {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (evt) {
......@@ -301,6 +311,7 @@
return new RSVP.Queue()
.push(function () {
var start,
k,
end,
range,
request_options = {
......@@ -308,7 +319,7 @@
"dataType": "blob",
"url": action,
"xhrFields": {
withCredentials: true
withCredentials: this._withCredentials
}
};
if (options.start !== undefined || options.end !== undefined) {
......@@ -330,6 +341,11 @@
range = "bytes=" + start + "-" + end;
}
request_options.headers = {Range: range};
for (k in this._headers) {
if (this._headers.hasOwnProperty(k)) {
request_options.headers[k] = this._headers[k];
}
}
}
return jIO.util.ajax(request_options);
})
......@@ -389,8 +405,9 @@
"data": data,
"dataType": "blob",
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
});
};
......@@ -507,8 +524,9 @@
local_roles: local_roles
}),
"xhrFields": {
withCredentials: true
}
withCredentials: this._withCredentials
},
"headers": this._headers
});
})
.push(function (response) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment