fix passport google oauth type (#9653)

This commit is contained in:
Mizunashi Mana
2016-06-19 11:15:32 +09:00
committed by Masahiro Wakame
parent 1b272795b6
commit 2373d3f801
2 changed files with 12 additions and 3 deletions
@@ -18,10 +18,11 @@ passport.use(new google.OAuthStrategy({
consumerSecret: process.env.GOOGLE_CONSUMER_SECRET,
callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL
},
function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) {
function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any, msg?: google.VerifyOptions) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
if (err) { return done(err); }
done(null, user);
else if(!user) return done(null, false, {message: 'not found user'});
return done(null, user);
});
})
);
+9 -1
View File
@@ -28,9 +28,17 @@ declare module 'passport-google-oauth' {
sessionKey?: string;
}
interface VerifyOptions {
message: string;
}
interface VerifyFunction {
(error: any, user?: any, msg?: VerifyOptions): void;
}
class OAuthStrategy implements passport.Strategy {
constructor(options: IOAuthStrategyOption,
verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
verify: (accessToken: string, refreshToken: string, profile: Profile, done: VerifyFunction) => void);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}