![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | lib/ | 2 years ago | - | |
![]() | CHANGELOG.md | 40 years ago | 3.2K | |
![]() | LICENSE | 40 years ago | 1.1K | 7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك] |
![]() | README.md | 40 years ago | 1.6K | f12eb36 documentaiton updates [كارل مبارك] |
![]() | package.json | 2 years ago | 1.6K | 7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك] |
Passport middleware for Koa
koa-passport version | koa version | branch |
---|---|---|
1.x | 1.x | v1.x |
2.x | 2.x | v2.x |
4.x | 2.x | master |
v3
ctx.passport.*
to ctx.state.*
(e.g. ctx.passport.user
to ctx.state.user
)ctx.req
(e.g. use ctx.login
instead of ctx.req.login
)err, user, info, status
(e.g. passport.authenticate('local', function(err, user, info, status) { ... })(ctx, next)
)// body parser
const bodyParser = require('koa-bodyparser')
app.use(bodyParser())
// Sessions
const session = require('koa-session')
app.keys = ['secret']
app.use(session({}, app))
const passport = require('koa-passport')
app.use(passport.initialize())
app.use(passport.session())
Passport's values and methods are exposed as follows:
app.use(async ctx => {
ctx.isAuthenticated()
ctx.isUnauthenticated()
await ctx.login()
ctx.logout()
ctx.state.user
})