update tests

This commit is contained in:
UrielCh
2017-04-10 15:47:39 -07:00
parent 78c6283deb
commit fe31e7760e
4 changed files with 67 additions and 5 deletions

View File

@@ -4,6 +4,7 @@
*/
import passport = require('passport');
import facebook = require('passport-facebook');
import express = require('express');
// just some test model
var User = {
@@ -25,6 +26,20 @@ passport.use(new facebook.Strategy({
})
);
passport.use(new facebook.Strategy({
clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID,
clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET,
callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL,
passReqToCallback: true
},
function(req: express.Request, accessToken:string, refreshToken:string, profile:facebook.Profile, done:(error:any, user?:any) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
})
);
passport.use(new facebook.Strategy({
clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID,
clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET,

View File

@@ -2,6 +2,7 @@
/**
* Created by jcabresos on 4/19/2014.
*/
import express = require("express");
import passport = require('passport');
import google = require('passport-google-oauth');
@@ -38,3 +39,17 @@ passport.use(new google.OAuth2Strategy({
});
})
);
passport.use(new google.OAuth2Strategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL,
passReqToCallback: true
},
function(req: express.Request, accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
})
);

View File

@@ -19,7 +19,7 @@ interface Profile extends passport.Profile {
_accessLevel: string;
}
interface IStrategyOption {
interface IStrategyOptionBase {
consumerKey: string;
consumerSecret: string;
callbackURL: string;
@@ -35,7 +35,11 @@ interface IStrategyOption {
skipExtendedUserProfile?: boolean;
}
interface IStrategyOptionWithRequest extends IStrategyOption {
interface IStrategyOption extends IStrategyOptionBase {
passReqToCallback?: false;
}
interface IStrategyOptionWithRequest extends IStrategyOptionBase {
passReqToCallback: true;
}

View File

@@ -2,6 +2,7 @@
/**
* Created by jcabresos on 4/19/2014.
*/
import express = require("express");
import passport = require('passport');
import twitter = require('passport-twitter');
@@ -15,9 +16,7 @@ var User = {
passport.use(new twitter.Strategy({
consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY,
consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET,
callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL,
passReqToCallback : true,
includeEmail: true
callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL
},
function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
@@ -26,3 +25,32 @@ passport.use(new twitter.Strategy({
});
})
);
passport.use(new twitter.Strategy({
consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY,
consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET,
callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL,
passReqToCallback : false
},
function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
})
);
passport.use(new twitter.Strategy({
consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY,
consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET,
callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL,
passReqToCallback : true,
includeEmail: true
},
function(req: express.Request, accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) {
User.findOrCreate(profile.id, profile.provider, function(err, user) {
if (err) { return done(err); }
done(null, user);
});
})
);