mod so one can set passwords a) for pads that are in no group and b) via the web interface

This commit is contained in:
jaseg 2011-12-06 22:00:42 +01:00
parent b0976a292f
commit dc8ff69553
5 changed files with 66 additions and 29 deletions

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);
},
isCorrectPassword: function(password)
@ -516,8 +520,7 @@ function generateSalt()
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;
}