diff options
author | Jan Lehnardt <jan@apache.org> | 2011-04-16 22:36:36 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2011-04-16 22:36:36 +0000 |
commit | 90c81fff314c8d7cbce1b1f25c29f2684b85e864 (patch) | |
tree | f17ed052dad25617f8fbc9d18b4e9c150f219c3a /share/www/script/jquery.couch.js | |
parent | 195d224a2bef2dd990d8214483caf3cb965797a8 (diff) | |
download | couchdb-90c81fff314c8d7cbce1b1f25c29f2684b85e864.tar.gz |
Make prepareUserDoc a public method.
Closes COUCHDB-1014
Patch by Benjamin Young.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1094076 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/jquery.couch.js')
-rw-r--r-- | share/www/script/jquery.couch.js | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js index 9e31cef17..75673bc0b 100644 --- a/share/www/script/jquery.couch.js +++ b/share/www/script/jquery.couch.js @@ -54,24 +54,6 @@ /** * @private */ - function prepareUserDoc(user_doc, new_password) { - if (typeof hex_sha1 == "undefined") { - alert("creating a user doc requires sha1.js to be loaded in the page"); - return; - } - var user_prefix = "org.couchdb.user:"; - user_doc._id = user_doc._id || user_prefix + user_doc.name; - if (new_password) { - // handle the password crypto - user_doc.salt = $.couch.newUUID(); - user_doc.password_sha = hex_sha1(new_password + user_doc.salt); - } - user_doc.type = "user"; - if (!user_doc.roles) { - user_doc.roles = []; - } - return user_doc; - } var uuidCache = []; @@ -206,7 +188,31 @@ db.saveDoc(user_doc, options); }); }, - + + /** + * Populates a user doc with a new password. + * @param {Object} user_doc User details + * @param {String} new_password New Password + */ + prepareUserDoc: function(user_doc, new_password) { + if (typeof hex_sha1 == "undefined") { + alert("creating a user doc requires sha1.js to be loaded in the page"); + return; + } + var user_prefix = "org.couchdb.user:"; + user_doc._id = user_doc._id || user_prefix + user_doc.name; + if (new_password) { + // handle the password crypto + user_doc.salt = $.couch.newUUID(); + user_doc.password_sha = hex_sha1(new_password + user_doc.salt); + } + user_doc.type = "user"; + if (!user_doc.roles) { + user_doc.roles = []; + } + return user_doc; + } + /** * Authenticate against CouchDB, the <code>options</code> parameter is *expected to have <code>name</code> and <code>password</code> fields. |