Skip to content

Commit

Permalink
Finish v0.8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
itayw committed May 9, 2015
2 parents 9b9b447 + 375e007 commit cbe8e02
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 166 deletions.
2 changes: 2 additions & 0 deletions lib/common/auth.js
Expand Up @@ -183,6 +183,8 @@ auth.generateToken = function (req, user, callback) {
/* istanbul ignore else */
if (joola.redis) {
return joola.redis.hmset(joola.config.namespace + ':auth:tokens:' + token._, token, function (err) {
if (err)
return callback(err);
joola.memory.set('token:' + token._, token, (joola.config.get('authentication:tokens:expireafter') || 20 * 60 * 1000 /*20 minutes*/));
token.user = JSON.parse(token.user);
joola.logger.trace({category: 'security'}, '[auth] generated token [' + token._ + '] for [' + token.user.username + '].');
Expand Down
9 changes: 7 additions & 2 deletions lib/common/index.js
Expand Up @@ -61,6 +61,7 @@ common.uuid = function (length) {
}
return result.join('');
}

return randomString(length || 32, 'abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789');
};

Expand Down Expand Up @@ -233,15 +234,15 @@ common.objToArray = function (obj) {
};

common.flatGetSet = function (obj, is, value) {
if (typeof is == 'string'){
if (typeof is == 'string') {
return common.flatGetSet(obj, is.split('.'), value);
}
else if (is.length == 1 && value !== undefined) {
if (value === null) {
//console.log('delete',obj, is[0]);
return delete obj[is[0]];
}
else{
else {
return obj[is[0]] = value; // jshint ignore:line
}
}
Expand Down Expand Up @@ -311,4 +312,8 @@ common.hashPassword = function (plainPassword, salt) {
/* istanbul ignore next */
return null;
}
};

common.inspect = function (obj) {
return require('util').inspect(obj, {depth: null, colors: true});
};
36 changes: 10 additions & 26 deletions lib/dispatch/beacon.js
Expand Up @@ -32,35 +32,25 @@ etl.verify = function (context, workspace, collection, documents, callback) {
documents = [documents];

var buildRowKey = function (obj) {
var key = '';
var hashCode = function(str){
var hash = 0;
if (str.length === 0) return hash;
for (var i = 0; i < str.length; i++) {
var char = str.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
var key = obj.timestamp.toISOString();
traverse.map(obj, function (x) {
if (x && typeof (x) === 'string') {

key += x;
}
return hash;
};
Object.keys(obj).forEach(function (k) {
var value = obj[k];
var type = typeof value;
if (type === 'string' || k === 'timestamp')
key += value;
});
key = joola.common.hash(key);
return key;
};

async.map(documents, function (doc, callback) {
try {
doc._key = buildRowKey(doc);
if (!doc.timestamp)
doc.timestamp = new Date();
else {
doc.timestamp = new Date(doc.timestamp.value || doc.timestamp);
}
doc._key = buildRowKey(doc);
}
catch (ex) {
return callback(ex);
Expand Down Expand Up @@ -332,14 +322,10 @@ exports.insert = {

etl.verify(context, workspace, collection, documents, function (err) {
if (err)
return setImmediate(function () {
return callback(err);
});
return callback(err);
etl.load(context, workspace, collection, documents, {}, function (err, documents) {
if (err)
return setImmediate(function () {
return callback(err);
});
return callback(err);

return setImmediate(function () {
var end_ts = new Date().getTime();
Expand Down Expand Up @@ -368,9 +354,7 @@ exports.insert = {
/* istanbul ignore next */
console.log(ex.stack);

return setImmediate(function () {
return callback(ex);
});
return callback(ex);
}
}
};
Expand Down

0 comments on commit cbe8e02

Please sign in to comment.