diff --git a/types/koa-passport/index.d.ts b/types/koa-passport/index.d.ts index 34fe0da391..0a011a06d5 100644 --- a/types/koa-passport/index.d.ts +++ b/types/koa-passport/index.d.ts @@ -21,8 +21,7 @@ import * as passport from "passport"; declare module "koa" { interface Context { - login(user: any): Promise; - login(user: any, options: any): Promise; + login(user: any, options?: any): Promise; logIn: Context["login"]; logout(): void; @@ -33,9 +32,7 @@ declare module "koa" { } } - declare namespace KoaPassport { - class KoaPassport { use(strategy: passport.Strategy): this; use(name: string, strategy: passport.Strategy): this; diff --git a/types/koa-passport/koa-passport-tests.ts b/types/koa-passport/koa-passport-tests.ts index c4c3948b92..42827a85ba 100644 --- a/types/koa-passport/koa-passport-tests.ts +++ b/types/koa-passport/koa-passport-tests.ts @@ -2,13 +2,11 @@ import * as Koa from 'koa'; import * as passport from 'koa-passport'; const app = new Koa(); -let ctx: Koa.Context; - app.use(passport.initialize()); app.use(passport.session()); -app.use(async (ctx: Koa.Context): Promise => { +app.use(async (ctx): Promise => { ctx.isAuthenticated(); ctx.isUnauthenticated(); ctx.login({}); @@ -16,8 +14,7 @@ app.use(async (ctx: Koa.Context): Promise => { ctx.state.user; }); - -app.use(async (ctx: Koa.Context, next: () => Promise) => { +app.use(async (ctx, next) => { return passport.authenticate('local', (user: any, info: any, status: any) => { if (user === false) { ctx.status = 401;