koa-passport
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -13,4 +13,10 @@ /** | ||
/** | ||
* Passport's HTTP IncomingMessage extension names | ||
*/ | ||
var requestExtensions = ['login', 'logIn', 'logout', 'logOut', | ||
'isAuthenticated', 'isUnauthenticated'] | ||
/** | ||
* Passport's initialization middleware for Koa. | ||
* | ||
* | ||
* @return {GeneratorFunction} | ||
@@ -22,3 +28,13 @@ * @api private | ||
return function*(next) { | ||
// koa <-> connect compatibility | ||
this.req.session = this.session | ||
this.req.query = this.request.query | ||
this.req.body = this.request.body | ||
// add aliases for passport's request extensions to `ctx` | ||
var ctx = this | ||
requestExtensions.forEach(function(method) { | ||
ctx[method] = ctx.req[method].bind(ctx.req) | ||
}) | ||
yield middleware.bind(middleware, this.req, this) | ||
@@ -41,5 +57,2 @@ yield next | ||
return function*(next) { | ||
// koa ↔ connect compatibility | ||
this.req.session = this.session | ||
this.req.query = this.query | ||
var ctx = this | ||
@@ -70,3 +83,3 @@ | ||
// call the connect middleware | ||
middleware(this.req, res, done) | ||
middleware(ctx.req, res, done) | ||
} | ||
@@ -81,3 +94,3 @@ | ||
} | ||
/** | ||
@@ -84,0 +97,0 @@ * Framework support for Koa. |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Passport middleware for Koa", | ||
@@ -10,0 +10,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# koa-passport | ||
# koa-passport | ||
[![NPM](https://badge.fury.io/js/koa-passport.png)](https://npmjs.org/package/koa-passport) | ||
@@ -10,9 +10,6 @@ [![Dependency Status](https://david-dm.org/rkusa/koa-passport.png?theme=shields.io)](https://david-dm.org/rkusa/koa-passport) | ||
```js | ||
// Body Parser & Query | ||
app.use(function*(next) { | ||
this.req.body = yield /* insert your body parser here */ | ||
// body parser | ||
var bodyParser = require('koa-bodyparser') | ||
app.use(bodyParser()) | ||
yield next | ||
}) | ||
// Sessions | ||
@@ -19,0 +16,0 @@ var session = require('koa-session') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6236
97
45