Skip to content

Commit

Permalink
Remove auth(ctx) signature
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Sep 13, 2017
1 parent 9c92f93 commit be7dc4b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unreleased
==========

* Drop support for Node.js below 0.8
* Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)`
* Use `safe-buffer` for improved Buffer API

1.1.0 / 2016-11-18
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ with `name` and `pass` properties, or `undefined` if the string is invalid.

## Example

Pass a node request or koa Context object to the module exported. If
parsing fails `undefined` is returned, otherwise an object with
`.name` and `.pass`.
Pass a Node.js request object to the module export. If parsing fails
`undefined` is returned, otherwise an object with `.name` and `.pass`.

<!-- eslint-disable no-unused-vars, no-undef -->

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function auth (req) {
}

// get header
var header = getAuthorization(req.req || req)
var header = getAuthorization(req)

// parse header
return parse(header)
Expand Down
7 changes: 0 additions & 7 deletions test/basic-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ describe('auth(req)', function () {
assert.equal(creds.pass, 'bar')
})

it('should accept a koa context', function () {
var ctx = { req: request('basic Zm9vOmJhcg==') }
var creds = auth(ctx)
assert.equal(creds.name, 'foo')
assert.equal(creds.pass, 'bar')
})

it('should reject null', function () {
assert.throws(auth.bind(null, null), /argument req is required/)
})
Expand Down

0 comments on commit be7dc4b

Please sign in to comment.