You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2011/04/17 00:36:36 UTC
svn commit: r1094076 - /couchdb/trunk/share/www/script/jquery.couch.js
Author: jan
Date: Sat Apr 16 22:36:36 2011
New Revision: 1094076
URL: http://svn.apache.org/viewvc?rev=1094076&view=rev
Log:
Make prepareUserDoc a public method.
Closes COUCHDB-1014
Patch by Benjamin Young.
Modified:
couchdb/trunk/share/www/script/jquery.couch.js
Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=1094076&r1=1094075&r2=1094076&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Sat Apr 16 22:36:36 2011
@@ -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.