npm-registry-client
Advanced tools
Comparing version 0.0.11 to 0.1.0
@@ -42,5 +42,27 @@ | ||
cb = done.call(this, cb) | ||
// pluck off any other username/password/token. it needs to be the | ||
// same as the user we're becoming now. replace them on error. | ||
var pre = { username: this.username | ||
, password: this.password | ||
, auth: this.auth | ||
, token: this.token } | ||
this.log.verbose("adduser", "before first PUT", userobj) | ||
this.token = null | ||
this.couchLogin.token = null | ||
this.username = username | ||
this.password = password | ||
this.auth = new Buffer(username + ':' + password).toString('base64') | ||
cb = done.call(this, cb, pre) | ||
var logObj = Object.keys(userobj).map(function (k) { | ||
if (k === 'salt' || k === 'password_sha') return [k, 'XXXXX'] | ||
return [k, userobj[k]] | ||
}).reduce(function (s, kv) { | ||
s[kv[0]] = kv[1] | ||
return s | ||
}, {}) | ||
this.log.verbose("adduser", "before first PUT", logObj) | ||
this.request('PUT' | ||
@@ -75,3 +97,3 @@ , '/-/user/org.couchdb.user:'+encodeURIComponent(username) | ||
}) | ||
this.log.verbose("adduser", "userobj", userobj) | ||
this.log.verbose("adduser", "userobj", logObj) | ||
this.request('PUT' | ||
@@ -86,3 +108,3 @@ , '/-/user/org.couchdb.user:'+encodeURIComponent(username) | ||
function done (cb) { | ||
function done (cb, pre) { | ||
return function (error, data, json, response) { | ||
@@ -92,2 +114,12 @@ if (!error && (!response || response.statusCode === 201)) { | ||
} | ||
// there was some kind of error, re-instate previous auth/token/etc. | ||
this.couchLogin.token = this.token = pre.token | ||
if (this.couchLogin.tokenSet) { | ||
this.couchLogin.tokenSet(pre.token) | ||
} | ||
this.username = pre.username | ||
this.password = pre.password | ||
this.auth = pre.auth | ||
this.log.verbose("adduser", "back", [error, data, json]) | ||
@@ -94,0 +126,0 @@ if (!error) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Client for the npm registry", | ||
"version": "0.0.11", | ||
"version": "0.1.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "git://github.com/isaacs/npm-registry-client" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66822
1045