Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
move whoami endpoint out of the package namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Jan 16, 2015
1 parent 33bd08a commit ba6b73e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/whoami.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ function whoami (uri, params, cb) {
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 (auth.username) return process.nextTick(cb.bind(this, null, auth.username))

this.request(url.resolve(uri, "-/whoami"), { auth : auth }, function (er, userdata) {
if (er) return cb(er)

cb(null, userdata.username)
Expand Down
7 changes: 5 additions & 2 deletions test/whoami.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ test("whoami call contract", function (t) {
})

test("whoami", function (t) {
server.expect("GET", "/whoami", function (req, res) {
server.expect("GET", "/-/whoami", function (req, res) {
t.equal(req.method, "GET")
// only available for token-based auth for now
t.equal(req.headers.authorization, "Bearer not-bad-meaning-bad-but-bad-meaning-wombat")
t.equal(
req.headers.authorization,
"Bearer not-bad-meaning-bad-but-bad-meaning-wombat"
)

res.json({username : WHOIAM})
})
Expand Down

0 comments on commit ba6b73e

Please sign in to comment.