From be7dc4bfc28692b86712679b900f659df564665e Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 12 Sep 2017 23:05:33 -0400 Subject: [PATCH] Remove auth(ctx) signature --- HISTORY.md | 1 + README.md | 5 ++--- index.js | 2 +- test/basic-auth.js | 7 ------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 7b1baa2..eb10766 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/README.md b/README.md index 476c90b..48d9ee4 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/index.js b/index.js index 4803a77..9106e64 100644 --- a/index.js +++ b/index.js @@ -63,7 +63,7 @@ function auth (req) { } // get header - var header = getAuthorization(req.req || req) + var header = getAuthorization(req) // parse header return parse(header) diff --git a/test/basic-auth.js b/test/basic-auth.js index 8e1d3ff..7633c6d 100644 --- a/test/basic-auth.js +++ b/test/basic-auth.js @@ -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/) })