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
diff --git a/jquery.couch.js b/jquery.couch.js
index f4c609b..ab1f865 100644
--- a/jquery.couch.js
+++ b/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 = [];
@@ -208,6 +190,30 @@
},
/**
+ * 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.
* @param {ajaxSettings} options