Permalink
Browse files

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
  • Loading branch information...
1 parent 195d224 commit 90c81fff314c8d7cbce1b1f25c29f2684b85e864 @janl janl committed Apr 16, 2011
Showing with 25 additions and 19 deletions.
  1. +25 −19 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.

0 comments on commit 90c81ff

Please sign in to comment.