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

Commit ba6b73e

Browse files
committed
move whoami endpoint out of the package namespace
1 parent 33bd08a commit ba6b73e

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

lib/whoami.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function whoami (uri, params, cb) {
1111
var auth = params.auth
1212
assert(auth && typeof auth === "object", "must pass auth to whoami")
1313

14-
this.request(url.resolve(uri, "whoami"), { auth : auth }, function (er, userdata) {
14+
if (auth.username) return process.nextTick(cb.bind(this, null, auth.username))
15+
16+
this.request(url.resolve(uri, "-/whoami"), { auth : auth }, function (er, userdata) {
1517
if (er) return cb(er)
1618

1719
cb(null, userdata.username)

test/whoami.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ test("whoami call contract", function (t) {
4949
})
5050

5151
test("whoami", function (t) {
52-
server.expect("GET", "/whoami", function (req, res) {
52+
server.expect("GET", "/-/whoami", function (req, res) {
5353
t.equal(req.method, "GET")
5454
// only available for token-based auth for now
55-
t.equal(req.headers.authorization, "Bearer not-bad-meaning-bad-but-bad-meaning-wombat")
55+
t.equal(
56+
req.headers.authorization,
57+
"Bearer not-bad-meaning-bad-but-bad-meaning-wombat"
58+
)
5659

5760
res.json({username : WHOIAM})
5861
})

0 commit comments

Comments
 (0)