This commit is contained in:
jaseg 2011-12-06 22:01:58 +01:00
commit e9f6a10039
6 changed files with 74 additions and 34 deletions

View file

@ -280,11 +280,11 @@ Example returns:
exports.setPublicStatus = function(padID, publicStatus, callback)
{
//ensure this is a group pad
if(padID.indexOf("$") == -1)
/*if(padID.indexOf("$") == -1)
{
callback({stop: "You can only get/set the publicStatus of pads that belong to a group"});
return;
}
}*/
//get the pad
getPadSafe(padID, true, function(err, pad)
@ -349,8 +349,8 @@ exports.setPassword = function(padID, password, callback)
//ensure this is a group pad
if(padID.indexOf("$") == -1)
{
callback({stop: "You can only get/set the password of pads that belong to a group"});
return;
//callback({stop: "You can only get/set the password of pads that belong to a group"});
//return;
}
//get the pad

View file

@ -202,7 +202,7 @@ exports.createGroupPad = function(groupID, padName, text, callback)
}
});
},
//ensure pad does not exists
//ensure pad does not exist
function (callback)
{
padManager.doesPadExists(padID, function(err, exists)
@ -278,8 +278,7 @@ function randomString(len)
var randomstring = '';
for (var i = 0; i < len; i++)
{
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
randomstring += chars[Math.floor(Math.random() * chars.length)];
}
return randomstring;
}

View file

@ -52,7 +52,7 @@ Class('Pad', {
publicStatus : {
is: 'rw',
init: false,
init: true,
getterName : 'getPublicStatus'
}, //publicStatus
@ -486,7 +486,11 @@ Class('Pad', {
},
setPassword: function(password)
{
this.passwordHash = password == null ? null : hash(password, generateSalt());
if(password == null){
this.passwordHash = null;
}else{
this.passwordHash = hash(password, generateSalt());
}
db.setSub("pad:"+this.id, ["passwordHash"], this.passwordHash);
},
getPasswordSalt: function()
@ -520,8 +524,7 @@ function generateSalt()
var randomstring = '';
for (var i = 0; i < len; i++)
{
var rnum = Math.floor(Math.random() * charset.length);
randomstring += charset[rnum];
randomstring += chars[Math.floor(Math.random() * chars.length)];
}
return randomstring;
}

View file

@ -35,7 +35,7 @@ var sessionManager = require("./SessionManager");
exports.checkAccess = function (padID, sessionID, token, password, callback)
{
// it's not a group pad, means we can grant access
if(padID.indexOf("$") == -1)
/*if(padID.indexOf("$") == -1)
{
//get author for this token
authorManager.getAuthor4Token(token, function(err, author)
@ -46,7 +46,7 @@ exports.checkAccess = function (padID, sessionID, token, password, callback)
//don't continue
return;
}
}*/
var groupID = padID.split("$")[0];
var padExists = false;

View file

@ -112,7 +112,7 @@ exports.doImport = function(req, res, padId)
//convert file to text
function(callback)
{
var randNum = Math.floor(Math.random()*new Date().getTime());
var randNum = Math.floor(Math.random()*0xFFFFFFFF);
destFile = tempDirectory + "eplite_import_" + randNum + ".txt";
abiword.convertFile(srcFile, destFile, "txt", callback);
},
@ -136,10 +136,13 @@ exports.doImport = function(req, res, padId)
//node on windows has a delay on releasing of the file lock.
//We add a 100ms delay to work around this
setTimeout(function()
{
callback(err);
}, 100);
if(os.type().indexOf("Windows") > -1)
{
setTimeout(function()
{
callback(err);
}, 100);
}
});
},