node/deps/npm/node_modules/npm-registry-client/lib/whoami.js
2014-09-24 17:15:10 -07:00

16 lines
342 B
JavaScript

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)
})
}