Skip to content

Commit

Permalink
scope token to the registry
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Jul 2, 2014
1 parent 4b85f1e commit 33dd0af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lib/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module.exports = adduser

var log = require("npmlog")
, url = require("url")
, npm = require("./npm.js")
, registry = npm.registry
, read = require("read")
Expand Down Expand Up @@ -133,7 +134,8 @@ function save (c, u, cb) {
}
npm.spinner.start()
// save existing configs, but yank off for this PUT
registry.adduser(npm.config.get("registry"), u.u, u.p, u.e, function (er, doc) {
var uri = npm.config.get("registry")
registry.adduser(uri, u.u, u.p, u.e, function (er, doc) {
npm.spinner.stop()
if (er) return cb(er)
registry.username = u.u
Expand All @@ -143,9 +145,10 @@ function save (c, u, cb) {
npm.config.del("_token", "user")
npm.config.set("username", u.u, "user")
npm.config.set("_password", u.p, "user")
// TODO: on-prem should move to scoped modules / multi-registry
if (doc && doc.token) {
npm.config.set("_authToken", doc.token, "user")
var munged = url.parse(uri)
delete munged.protocol
npm.config.set(url.format(munged) + ":_authToken", doc.token, "user")
}
npm.config.set("email", u.e, "user")
log.info("adduser", "Authorized user %s", u.u)
Expand Down
5 changes: 3 additions & 2 deletions node_modules/npm-registry-client/lib/request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node_modules/npm-registry-client/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/tap/config-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ var CONFS = {}
var DOC = {}

var exceptions = [
path.resolve(lib, "adduser.js"),
path.resolve(lib, "config.js"),
path.resolve(lib, "publish.js"),
path.resolve(lib, "utils", "lifecycle.js"),
path.resolve(lib, "utils", "map-name-to-registry.js")
path.resolve(lib, "utils", "map-name-to-registry.js"),
path.resolve(nm, "npm-registry-client", "lib", "request.js")
]

test("get files", function (t) {
Expand Down

0 comments on commit 33dd0af

Please sign in to comment.