mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 03:29:46 +00:00

PR-URL: https://github.com/iojs/io.js/pull/266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
20 lines
582 B
JavaScript
20 lines
582 B
JavaScript
module.exports = whoami
|
|
|
|
var url = require("url")
|
|
, assert = require("assert")
|
|
|
|
function whoami (uri, params, cb) {
|
|
assert(typeof uri === "string", "must pass registry URI to whoami")
|
|
assert(params && typeof params === "object", "must pass params to whoami")
|
|
assert(typeof cb === "function", "must pass callback to whoami")
|
|
|
|
var auth = params.auth
|
|
assert(auth && typeof auth === "object", "must pass auth to whoami")
|
|
|
|
this.request(url.resolve(uri, "whoami"), { auth : auth }, function (er, userdata) {
|
|
if (er) return cb(er)
|
|
|
|
cb(null, userdata.username)
|
|
})
|
|
}
|