Skip to content

Commit be7dc4b

Browse files
committed
Remove auth(ctx) signature
1 parent 9c92f93 commit be7dc4b

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ unreleased
22
==========
33

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

78
1.1.0 / 2016-11-18

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ with `name` and `pass` properties, or `undefined` if the string is invalid.
3939

4040
## Example
4141

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

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

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function auth (req) {
6363
}
6464

6565
// get header
66-
var header = getAuthorization(req.req || req)
66+
var header = getAuthorization(req)
6767

6868
// parse header
6969
return parse(header)

test/basic-auth.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ describe('auth(req)', function () {
2323
assert.equal(creds.pass, 'bar')
2424
})
2525

26-
it('should accept a koa context', function () {
27-
var ctx = { req: request('basic Zm9vOmJhcg==') }
28-
var creds = auth(ctx)
29-
assert.equal(creds.name, 'foo')
30-
assert.equal(creds.pass, 'bar')
31-
})
32-
3326
it('should reject null', function () {
3427
assert.throws(auth.bind(null, null), /argument req is required/)
3528
})

0 commit comments

Comments
 (0)