node/deps/npm/node_modules/npm-registry-client/lib/whoami.js

16 lines
342 B
JavaScript
Raw Normal View History

2014-09-25 05:41:07 +08:00
module.exports = whoami
var url = require("url")
function whoami (uri, cb) {
if (!this.conf.getCredentialsByURI(uri)) {
return cb(new Error("Must be logged in to see who you are"))
}
this.request("GET", url.resolve(uri, "whoami"), null, function (er, userdata) {
if (er) return cb(er)
cb(null, userdata.username)
})
}