summaryrefslogtreecommitdiff
path: root/deps/npm/lib/whoami.js
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-03-13 02:07:27 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-03-15 21:41:52 -0400
commit7d0baf174155195bcc93ec63716118a3696095d7 (patch)
tree7964cba8d07b6f0954e43497a4d40a9b5a4de814 /deps/npm/lib/whoami.js
parent4eb8810a27a710bcfdf15fc03fbb22a65e655aff (diff)
downloadnode-new-7d0baf174155195bcc93ec63716118a3696095d7.tar.gz
deps: upgrade npm to 2.7.1
PR-URL: https://github.com/iojs/io.js/pull/1142 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'deps/npm/lib/whoami.js')
-rw-r--r--deps/npm/lib/whoami.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/deps/npm/lib/whoami.js b/deps/npm/lib/whoami.js
index 42cede1b82..d92a6574a1 100644
--- a/deps/npm/lib/whoami.js
+++ b/deps/npm/lib/whoami.js
@@ -14,14 +14,6 @@ function whoami (args, silent, cb) {
var registry = npm.config.get("registry")
if (!registry) return cb(new Error("no default registry set"))
- function noUser () {
- // At this point, if they have a credentials object, it doesn't have a
- // token or auth in it. Probably just the default registry.
- var msg = "Not authed. Run 'npm adduser'"
- if (!silent) console.log(msg)
- cb(null, msg)
- }
-
var auth = npm.config.getCredentialsByURI(registry)
if (auth) {
if (auth.username) {
@@ -31,7 +23,13 @@ function whoami (args, silent, cb) {
else if (auth.token) {
return npm.registry.whoami(registry, { auth : auth }, function (er, username) {
if (er) return cb(er)
- if (!username) return noUser()
+ if (!username) {
+ var needNewSession = new Error(
+ "Your auth token is no longer valid. Please log in again."
+ )
+ needNewSession.code = 'ENEEDAUTH'
+ return cb(needNewSession)
+ }
if (!silent) console.log(username)
cb(null, username)
@@ -39,5 +37,11 @@ function whoami (args, silent, cb) {
}
}
- process.nextTick(noUser)
+ // At this point, if they have a credentials object, it doesn't have a token
+ // or auth in it. Probably just the default registry.
+ var needAuth = new Error(
+ "'npm whoami' requires you to be logged in."
+ )
+ needAuth.code = 'ENEEDAUTH'
+ process.nextTick(cb.bind(this, needAuth))
}