mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-14 05:50:20 +00:00
lint
This commit is contained in:
Vendored
+1
-4
@@ -21,8 +21,7 @@ import * as passport from "passport";
|
||||
|
||||
declare module "koa" {
|
||||
interface Context {
|
||||
login(user: any): Promise<void>;
|
||||
login(user: any, options: any): Promise<void>;
|
||||
login(user: any, options?: any): Promise<void>;
|
||||
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;
|
||||
|
||||
@@ -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<void> => {
|
||||
app.use(async (ctx): Promise<void> => {
|
||||
ctx.isAuthenticated();
|
||||
ctx.isUnauthenticated();
|
||||
ctx.login({});
|
||||
@@ -16,8 +14,7 @@ app.use(async (ctx: Koa.Context): Promise<void> => {
|
||||
ctx.state.user;
|
||||
});
|
||||
|
||||
|
||||
app.use(async (ctx: Koa.Context, next: () => Promise<any>) => {
|
||||
app.use(async (ctx, next) => {
|
||||
return passport.authenticate('local', (user: any, info: any, status: any) => {
|
||||
if (user === false) {
|
||||
ctx.status = 401;
|
||||
|
||||
Reference in New Issue
Block a user