Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-06-18 02:40:03 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-07-02 05:16:43 +0400
commit33dd0afcb3cc3dee90fbe32906d1b489b0cf05f0 (patch)
tree7acbf0bfa90c4c1406677c59a1016a7aced01e81 /lib
parent4b85f1e3db16ecc6988a59782d1fe5a434da0eb1 (diff)
scope token to the registry
Diffstat (limited to 'lib')
-rw-r--r--lib/adduser.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/adduser.js b/lib/adduser.js
index 62e6ce0b8..8315809c5 100644
--- a/lib/adduser.js
+++ b/lib/adduser.js
@@ -2,6 +2,7 @@
module.exports = adduser
var log = require("npmlog")
+ , url = require("url")
, npm = require("./npm.js")
, registry = npm.registry
, read = require("read")
@@ -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
@@ -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)