diff options
author | Chad Weider <cweider@oofn.net> | 2012-01-28 17:38:23 -0800 |
---|---|---|
committer | Chad Weider <cweider@oofn.net> | 2012-02-10 14:52:34 -0800 |
commit | 363e1685618b1bb05802a221021549eb0ee7a3bd (patch) | |
tree | 2f23e58b4ac2b9459e6f1658792940f5e9fa89ac /node/db | |
parent | 34edba3adfb2c15543273d3de4ddc74abf896e8c (diff) | |
download | etherpad-lite-363e1685618b1bb05802a221021549eb0ee7a3bd.zip |
Share `randomString` method.
This simply shares a common implementation and makes no judgements on the validity of its use. The string created is not a secure random number, so some uses of it may not be applicable.
Diffstat (limited to 'node/db')
-rw-r--r-- | node/db/AuthorManager.js | 4 | ||||
-rw-r--r-- | node/db/GroupManager.js | 3 | ||||
-rw-r--r-- | node/db/Pad.js | 11 | ||||
-rw-r--r-- | node/db/ReadOnlyManager.js | 4 | ||||
-rw-r--r-- | node/db/SecurityManager.js | 4 | ||||
-rw-r--r-- | node/db/SessionManager.js | 3 |
6 files changed, 12 insertions, 17 deletions
diff --git a/node/db/AuthorManager.js b/node/db/AuthorManager.js index 7c054a56..9baf6347 100644 --- a/node/db/AuthorManager.js +++ b/node/db/AuthorManager.js @@ -18,11 +18,11 @@ * limitations under the License. */ +var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var db = require("./DB").db; var async = require("async"); - -var randomString = require("../utils/randomstring"); +var randomString = CommonCode.require('/pad_utils').randomString; /** * Checks if the author exists diff --git a/node/db/GroupManager.js b/node/db/GroupManager.js index 7e3b7d6d..bd294ba6 100644 --- a/node/db/GroupManager.js +++ b/node/db/GroupManager.js @@ -18,9 +18,10 @@ * limitations under the License. */ +var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var customError = require("../utils/customError"); -var randomString = require("../utils/randomstring"); +var randomString = CommonCode.require('/pad_utils').randomString; var db = require("./DB").db; var async = require("async"); var padManager = require("./PadManager"); diff --git a/node/db/Pad.js b/node/db/Pad.js index f29f7173..99a53143 100644 --- a/node/db/Pad.js +++ b/node/db/Pad.js @@ -6,6 +6,7 @@ var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var Changeset = CommonCode.require("/Changeset"); var AttributePoolFactory = CommonCode.require("/AttributePoolFactory"); +var randomString = CommonCode.require('/pad_utils').randomString; var db = require("./DB").db; var async = require("async"); var settings = require('../utils/Settings'); @@ -478,15 +479,7 @@ function hash(password, salt) function generateSalt() { - var len = 86; - var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./"; - var randomstring = ''; - for (var i = 0; i < len; i++) - { - var rnum = Math.floor(Math.random() * chars.length); - randomstring += chars.substring(rnum, rnum + 1); - } - return randomstring; + return randomstring(86); } function compare(hashStr, password) diff --git a/node/db/ReadOnlyManager.js b/node/db/ReadOnlyManager.js index 1e5079c5..e5dab99b 100644 --- a/node/db/ReadOnlyManager.js +++ b/node/db/ReadOnlyManager.js @@ -18,11 +18,11 @@ * limitations under the License. */ +var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var db = require("./DB").db; var async = require("async"); - -var randomString = require("../utils/randomstring"); +var randomString = CommonCode.require('/pad_utils').randomString; /** * returns a read only id for a pad diff --git a/node/db/SecurityManager.js b/node/db/SecurityManager.js index 4b86d868..33ab37d4 100644 --- a/node/db/SecurityManager.js +++ b/node/db/SecurityManager.js @@ -18,6 +18,7 @@ * limitations under the License. */ +var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var db = require("./DB").db; var async = require("async"); @@ -25,8 +26,7 @@ var authorManager = require("./AuthorManager"); var padManager = require("./PadManager"); var sessionManager = require("./SessionManager"); var settings = require("../utils/Settings") - -var randomString = require("../utils/randomstring"); +var randomString = CommonCode.require('/pad_utils').randomString; /** * This function controlls the access to a pad, it checks if the user can access a pad. diff --git a/node/db/SessionManager.js b/node/db/SessionManager.js index 084d4a69..c5af33c6 100644 --- a/node/db/SessionManager.js +++ b/node/db/SessionManager.js @@ -18,9 +18,10 @@ * limitations under the License. */ +var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var customError = require("../utils/customError"); -var randomString = require("../utils/randomstring"); +var randomString = CommonCode.require('/pad_utils').randomString; var db = require("./DB").db; var async = require("async"); var groupMangager = require("./GroupManager"); |