有谁知道我是否可以在couchdb 1.2中更改密码?要创建一个用户,我有一个获取用户信息的表单,然后像这样发布到_users数据库(下面的url中的'users'代理):
// Create a user
var userObj = {
_id: "org.couchdb.user:test",
type: "user",
name: "test",
roles: ["user"],
emailAddress: "test@testy.com",
firstName: "Test",
lastName: "Test",
password: "password"
};
$.ajax({
url: "/users/org.couchdb.user:test",
type: "PUT",
dataType: "json",
contentType:"application/json",
data: JSON.stringify(userObj)
});
Run Code Online (Sandbox Code Playgroud)
Couchdb 1.2为我生成密码哈希和盐并存储用户.它很棒.要更新密码,我尝试检索用户,删除password_sha和salt字段,添加密码字段,然后重新发布文档.我希望Couch能为我重新计算password_sha和salt字段并更新文档,但事实并非如此.password_sha和salt字段未更新.
// Update a user
$.get("/users/org.couchdb.user:test")
.done(function(userDoc){
delete userDoc.password_sha;
delete userDoc.salt
userDoc.password = "test";
$.ajax({
url: "/users/org.couchdb.user:test",
type: "PUT",
dataType: "json",
contentType:"application/json",
data: userDoc
});
});
Run Code Online (Sandbox Code Playgroud)
我怀疑沙发只会在创建文档时生成password_sha和salt字段.如果是这种情况,我应该生成自己的password_sha和salt字段并将其发布到更新的doc中吗?我在这里错过了什么吗?
谢谢!