improve support of passReqToCallback option in passport Strategies for facebook, google-oauth2, local and twitter

This commit is contained in:
UrielCh
2017-04-10 15:20:54 -07:00
parent cea4fdd8a1
commit 78c6283deb
4 changed files with 21 additions and 15 deletions
+5 -12
View File
@@ -11,9 +11,9 @@ import passport = require('passport');
import express = require('express');
interface Profile extends passport.Profile {
gender: string;
profileUrl: string;
username: string;
gender?: string;
profileUrl?: string;
username?: string;
_raw: string;
_json: any;
@@ -33,15 +33,8 @@ interface IStrategyOption {
profileFields?: string[];
}
interface IStrategyOptionWithRequest {
clientID: string;
clientSecret: string;
callbackURL: string;
scopeSeparator?: string;
enableProof?: boolean;
profileFields?: string[];
passReqToCallback: boolean;
interface IStrategyOptionWithRequest extends IStrategyOption {
passReqToCallback: true;
}
interface VerifyFunction {
+7
View File
@@ -62,9 +62,16 @@ interface IOAuth2StrategyOption {
openIDRealm?: string;
}
interface IOAuth2StrategyOptionWithRequest extends IOAuth2StrategyOption {
passReqToCallback: true;
}
declare class OAuth2Strategy implements passport.Strategy {
constructor(options: IOAuth2StrategyOption,
verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
constructor(options: IOAuth2StrategyOptionWithRequest,
verify: (req: express.Request, accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}
+2 -2
View File
@@ -13,13 +13,13 @@ import express = require('express');
interface IStrategyOptions {
usernameField?: string;
passwordField?: string;
passReqToCallback?: boolean;
passReqToCallback?: false;
}
interface IStrategyOptionsWithRequest {
usernameField?: string;
passwordField?: string;
passReqToCallback: boolean;
passReqToCallback: true;
}
interface IVerifyOptions {
+7 -1
View File
@@ -24,7 +24,6 @@ interface IStrategyOption {
consumerSecret: string;
callbackURL: string;
passReqToCallback?: true;
includeEmail?: true;
reguestTokenURL?: string;
@@ -36,9 +35,16 @@ interface IStrategyOption {
skipExtendedUserProfile?: boolean;
}
interface IStrategyOptionWithRequest extends IStrategyOption {
passReqToCallback: true;
}
declare class Strategy implements passport.Strategy {
constructor(options: IStrategyOption,
verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
constructor(options: IStrategyOptionWithRequest,
verify: (req: express.Request, accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}