add ExtractJwt.fromExtractors (#16684)

This commit is contained in:
yeyanbo
2017-06-02 22:34:00 +08:00
committed by Andy
parent f9a46cbb2e
commit 9676dec49d
2 changed files with 2 additions and 0 deletions

View File

@@ -43,4 +43,5 @@ export declare namespace ExtractJwt {
export function fromUrlQueryParameter(param_name: string): JwtFromRequestFunction;
export function fromAuthHeaderWithScheme(auth_scheme: string): JwtFromRequestFunction;
export function fromAuthHeader(): JwtFromRequestFunction;
export function fromExtractors(extractors: JwtFromRequestFunction[]): JwtFromRequestFunction;
}

View File

@@ -31,6 +31,7 @@ opts.jwtFromRequest = ExtractJwt.fromHeader('x-api-key');
opts.jwtFromRequest = ExtractJwt.fromBodyField('field_name');
opts.jwtFromRequest = ExtractJwt.fromUrlQueryParameter('param_name');
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('param_name');
opts.jwtFromRequest = ExtractJwt.fromExtractors([ExtractJwt.fromHeader('x-api-key'), ExtractJwt.fromBodyField('field_name'), ExtractJwt.fromUrlQueryParameter('param_name')]);
opts.jwtFromRequest = (req: Request) => { return req.query.token; };
declare function findUser(condition: {id: string}, callback: (error: any, user :any) => void): void;