I am using jquery.couch.js to do signup/login/logout to a CouchDB _users database in my Sproutcore application. Is anyone aware of a method for changing user _id and password?
2 Answers
As far as I know the user id cannot be changed but the password can.
The CouchDB documentation describes the process of changing a user password in detail, short:
Get the
org.couchdb.user:<myuser>documentAdd a password field with the plaintext password
Store the document back to the
_usersdatabase
As soon as the document is in the database, the CouchDB rehashes the plaintext password using PBKDF2 (at least since CouchDB 1.3).
Comments
Unfortunately, there is no built-in API to do this. The best thing for now is to read the jquery.couch.js code for account creation and use the same code or algorithms to do account modification.
Specifically, you need to update the password_sha and salt values to change a password. To change a user name, you must make a new document, then delete the old document. Just keep the _id and name values in sync and you'll be okay.