1
0
Fork 0

fix cloning

This commit is contained in:
Jan Steemann 2013-02-21 15:12:50 +01:00
parent 2e536fbac6
commit 35f6b3f054
4 changed files with 36 additions and 6 deletions

View File

@ -413,6 +413,7 @@ describe ArangoDB do
doc.parsed_response['active'].should eq(false)
doc.parsed_response['extra'].should eq({ "foo" => true })
doc.parsed_response.should_not have_key("passwd")
doc.parsed_response.should_not have_key("password")
end
end

View File

@ -69,7 +69,6 @@ function GET_api_user (req, res) {
var username = decodeURIComponent(req.suffix[0]);
try {
var result = users.document(username);
actions.resultOk(req, res, actions.HTTP_OK, result)
}
catch (err) {

View File

@ -29,6 +29,7 @@
////////////////////////////////////////////////////////////////////////////////
var internal = require("internal"); // OK: reloadAuth, time
var _ = require("underscore");
var reloadAuth = internal.reloadAuth;
var arangodb = require("org/arangodb");
@ -413,9 +414,11 @@ exports.document = function (username) {
throw err;
}
delete user.passwd;
return user;
return {
user: user.user,
active: user.active,
extra: user.extra || { }
};
};
////////////////////////////////////////////////////////////////////////////////

View File

@ -32,7 +32,6 @@ var arangodb = require("org/arangodb");
var internal = require("internal");
var console = require("console");
var moduleExists = function(name) { return module.exists; };
var _ = require("underscore");
// -----------------------------------------------------------------------------
// --SECTION-- private variables
@ -1004,6 +1003,34 @@ function reloadRouting () {
defineRoute(route, storage, url, callback);
};
// .............................................................................
// deep-copy a route object
// .............................................................................
clone = function (obj) {
if (obj === null || typeof(obj) !== "object") {
return obj;
}
var copy, a;
if (Array.isArray(obj)) {
copy = [ ];
obj.forEach(function (i) {
copy.push(clone(i));
});
}
else if (obj instanceof Object) {
copy = { };
for (a in obj) {
if (obj.hasOwnProperty(a)) {
copy[a] = clone(obj[a]);
}
}
}
return copy;
};
// .............................................................................
// loop over the routes or routes bundle
@ -1011,7 +1038,7 @@ function reloadRouting () {
while (routes.hasNext()) {
// clone the route object so the barrier for the collection can be removed soon
var route = _.clone(routes.next());
var route = clone(routes.next());
var r;
if (route.hasOwnProperty('routes') || route.hasOwnProperty('middleware')) {